Search code examples
rboostpredictadaboost

Adaboost in R: Predict for data that does not have dependent variable


I tried to use boosting in R from adabag package.

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.

Is there any way, I can predict for the test data which does not have dependent variable?


Solution

  • One way you can resolve this error is - By injecting dummy values manually.

    For Example:

    test$Y = as.factor(round(runif(nrow(test))))
    

    This should help the model understand whenever the test data doesn't have the Output variable.