- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Friedman 和 Popescu 2008 https://projecteuclid.org/euclid.aoas/1223908046 中描述的方法确定 gbm 模型中的哪些交互作用是重要的。 .我的 gbm 是一个有 9 个不同类别的分类模型。
我正在努力将第 8.3 节翻译成代码以在 R 中运行。
我认为整个过程是:
最佳答案
总体而言,该过程是中和 y
中的交互效应的一种优雅方式。通过置换/重新分配建模对交互的额外贡献。额外的贡献可以通过完整模型和加法模型之间的边际来捕获。
- What is subscript
i
? Is it the number of iterations in the bootstrap?
N
每次迭代中的样本。
- How is each artificial data set different from the others?
X
跨数据集相同。响应值
Y~
由于
equation 47
中边距的随机排列而不同
equation 48
中的随机实现(仅适用于分类结果) .
- Are we subbing the Pr(b_i = 1) into
equation 48
?
Y
是二进制的。
- How can this be done with multinomial classification?
- How would one implement this in R? Preferably using the
gbm
package.
{X1,X2,Y}
尺寸
N
=200 其中
Y
具有由
Y1
确定的概率实现的三类(
Y2
、
Y3
、
X1
) ,
X2
.互动部分
X1
*
X2
在
Y1
,而添加部分在
Y2
,
Y3
.
set.seed(1)
N <- 200
X1 <- rnorm(N) # 2 predictors
X2 <- rnorm(N)
#log-odds for 3 categories
Y1 <- 2*X1*X2 + rnorm(N, sd=1/10) # interaction
Y2 <- X1^2 + rnorm(N, sd=1/10) #additive
Y3 <- X2^2 + rnorm(N, sd=1/10) #additive
Y <- rep(NA, N) # Multinomial outcome with 3 categories
for (i in 1:N)
{
prob <- 1 / (1 + exp(-c(Y1[i],Y2[i],Y3[i]))) #logistic regression
Y[i] <- which.max(rmultinom(1, 10000, prob=prob)) #realisation from prob
}
Y <- factor(Y)
levels(Y) <- c('Y1','Y2','Y3')
table(Y)
#Y1 Y2 Y3
#38 75 87
dat = data.frame(Y, X1, X2)
head(dat)
# Y X1 X2
# 2 -0.6264538 0.4094018
# 3 0.1836433 1.6888733
# 3 -0.8356286 1.5865884
# 2 1.5952808 -0.3309078
# 3 0.3295078 -2.2852355
# 3 -0.8204684 2.4976616
max.depth
训练完整模型和加法模型= 2 和 1 分别。 library(gbm)
n.trees <- 100
F_full <- gbm(Y ~ ., data=dat, distribution='multinomial', n.trees=n.trees, cv.folds=3,
interaction.depth=2) # consider interactions
F_additive <- gbm(Y ~ ., data=dat, distribution='multinomial', n.trees=n.trees, cv.folds=3,
interaction.depth=1) # ignore interactions
#use improved prediction as interaction strength
interaction_strength_original <- min(F_additive$cv.error) - min(F_full$cv.error)
> 0.1937891
#randomly permute margins (residuals) of log-odds to remove any interaction effects
margin <- predict(F_full, n.trees=gbm.perf(F_full, plot.it=FALSE), type='link')[,,1] -
predict(F_additive, n.trees=gbm.perf(F_additive, plot.it=FALSE), type='link')[,,1]
margin <- apply(margin, 2, sample) #independent permutation for each category (Y1, Y2, Y3)
Y_art <- rep(NA, N) #response values of an artificial dataset
for (i in 1:N)
{
prob <- predict(F_additive, n.trees=gbm.perf(F_additive, plot.it=FALSE), type='link',
newdata=dat[i,])
prob <- prob + margin[i,] # equation (47)
prob <- 1 / (1 + exp(-prob))
Y_art[i] <- which.max(rmultinom(1, 1000, prob=prob)) #Similar to random realisation in equation (49)
}
Y_art <- factor(Y_art)
levels(Y_art) = c('Y1','Y2','Y3')
table(Y_art)
#Y1 Y2 Y3
#21 88 91
max.depth
在此人工数据上训练新模型(2) 同实物模型F_full_art = gbm(Y_art ~ ., distribution='multinomial', n.trees=n.trees, cv.folds=3,
data=data.frame(Y_art, X1, X2),
interaction.depth=2)
F_additive_art = gbm(Y_art ~ ., distribution='multinomial', n.trees=n.trees, cv.folds=3,
data=data.frame(Y_art, X1, X2),
interaction.depth=1)
interaction_strength_art = min(F_additive_art$cv.error) - min(F_full_art$cv.error)
> 0.01323959 # much smaller than interaction_strength_original in step 1.
interaction_strength_art <- NULL
for (j in 1:10)
{
print(j)
interaction_strength_art <- c(interaction_strength_art, step_2_to_4())
}
summary(interaction_strength_art)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
#-0.052648 -0.019415 0.001124 -0.004310 0.012759 0.042058
interaction_strength_original
> 0.1937891
关于r - 为 gbm 交互强度实现零分布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54464804/
我正在开发一个录音机应用程序。我想知道在录制音频时有什么方法可以找到音频的强度。我不想将录音保存在任何地方。我只想向用户展示麦克风捕捉到的声音是否大于预定义的阈值。 假设如果声音低于 2 分贝,它应该
我正在尝试让一个基本服务器(从 Beginning Python 复制)来发送一个 str。 错误: c.send( "XXX" ) TypeError: must be bytes or buffe
我陷入了一个问题,不知道去哪里看。我需要增加图像中特定颜色的强度,例如 R、G 或蓝色。当我这样做时,某些颜色无法正确呈现。 下面是我为测试拍摄的图像: 现在当我像绿色一样增加时: A = Color
我不希望我的背景图片太模糊。没有调整模糊强度的属性吗? let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light) blurEffect
我使用 OpenCV 2.4.11+Qt 并尝试制作视频并更改红色/蓝色或绿色 channel 的强度,但没有找到任何功能或设置来执行此操作。有谁知道如何做到这一点? 最佳答案 如果您只想更改一个特定
当我有 x、y、强度时,我不知道如何创建热图(或等高线图)。我有一个看起来像这样的文件: 0,1,6 0,2,10 .... 到目前为止: with open('eye_.txt', 'r') as
有谁有一些可以在 iPhone 应用程序中使用的代码,让我可以看到 wifi 的强度吗?我有一个连接密集型操作,并且希望它们不在不稳定区域 最佳答案 这可能会帮助您走上正确的道路...... http
当从 RGB 转换为灰度时,据说应该对 R、G 和 B channel 应用特定的权重。这些权重是:0.2989、0.5870、0.1140。 据说这是因为人类对这三种颜色的感知/感受不同。有时也有人
Eclipse SSH key 生成屏幕(常规 -> 网络连接 -> SSH2)生成 1024 位 RSA key ,该 key 太弱而无法使用 ( http://news.netcraft.com/
当从 RGB 转换为灰度时,据说应该对 R、G 和 B channel 应用特定的权重。这些权重是:0.2989、0.5870、0.1140。 据说这是因为人类对这三种颜色的感知/感受不同。有时也有人
我们的网络应用程序使用 the Vibrate API对于微妙的按钮按下效果: window.navigator.vibrate(5); 但在我的新手机上,感觉不那么微妙,更像是我的手机正试图从我手中
我的应用程序应扫描周围的 Wifi 信号并列出网络名称及其 RSSI。 我在谷歌上找不到任何关于如何做的线索。有人可以举个例子或者至少指出其他地方我可以找到答案吗? 最佳答案 我认为这不可能!不管是
所以我的图像有一些黑点,它们看起来很简单,所以我想我可以创建一个亮度图,将其反转,然后将其应用到我的图像以消除黑点。然而,我所能找到的只有两种均衡方法:均衡整个图像(使用直方图)或将图像分割成深色和浅
我是一名优秀的程序员,十分优秀!