R中的Adaboost:预测没有因变量的数据
Adaboost in R: Predict for data that does not have dependent variable
我尝试在 adabag 包中使用 R 中的提升。
library(adabag)
model = boosting(survived ~ ., data=train, boos=TRUE, mfinal=20)
# Now I tried to predict using the model for test dataset like this:
pred = predict(model,test[-1],type = "prob")
# IT gave me the following error
Error in [.data.frame
(newdata, , as.character(object$formula[[2]])) :
undefined columns selected
# But if i give:
pred = predict(model,test,type = "prob")
It predicts and we can get probabilities, confusion etc.
有什么办法可以预测没有因变量的测试数据?
解决此错误的一种方法是 - 通过手动注入虚拟值。
例如:
test$Y = as.factor(round(runif(nrow(test))))
这应该有助于模型在测试数据没有输出变量时理解。
我尝试在 adabag 包中使用 R 中的提升。
library(adabag)
model = boosting(survived ~ ., data=train, boos=TRUE, mfinal=20)
# Now I tried to predict using the model for test dataset like this:
pred = predict(model,test[-1],type = "prob")
# IT gave me the following error
Error in
[.data.frame
(newdata, , as.character(object$formula[[2]])) : undefined columns selected
# But if i give:
pred = predict(model,test,type = "prob")
It predicts and we can get probabilities, confusion etc.
有什么办法可以预测没有因变量的测试数据?
解决此错误的一种方法是 - 通过手动注入虚拟值。
例如:
test$Y = as.factor(round(runif(nrow(test))))
这应该有助于模型在测试数据没有输出变量时理解。