我正在尝试使用 bartCause 包在 R 中构建提升模型。不幸的是,我无法以正确的方式集成数据框 -错误消息:
$<-.data.frame`(`*tmp*`, "lift", value = c(0.159231848781688, :
replacement has 160 rows, data has 2595
使用的代码:
x = as.matrix(calibration[,-c(1:3)])
y = calibration$churn
z = calibration$treatment
bart = bartc(y, z, x,
method.trt = "bart",
method.rsp = "bart",
estimand="att", #average treatment effect on the treated
n.samples = 20L,
n.chains = 8L, #Integer specifying how many independent tree sets and fits should be calculated.
n.burn = 10L,
n.threads = 4L, #Integer specifying how many threads to use for parallelization
n.trees = 1000L,
keepTrees = TRUE, #necessary for prediction!
verbose = FALSE)
pred_uplift <- predict(bart, validation[,-c(1:3)], combineChains = TRUE)
pred <- pred_uplift
validation$lift <- - pred[,1] + pred[,2]
校准数据:(2595 个观测变量,共 15 个变量) 在此处输入图像描述
验证数据:(2595 个变量,共 15 个变量) 在此处输入图像描述