I trained an XGBoost model using mlr package. I need to make a prediction on a test set that does not have the target variable. I should just predict the target variable. If I do this:
testF.pred <- predict(xgmodel,X_test)
The error is:
Error in predict.WrappedModel(xgmodel, X_test) :
Assertion on 'task' failed: Must inherit from class 'Task', but has class 'data.frame'.
I should define a task to predict the target variable. However, If I want to create a task,
mytest_task <- makeClassifTask(data = X_test)
testF.pred <- predict(xgmodel,mytest_task)
The error is:
Error in assertString(target) :
argument "target" is missing, with no default
How I should make a task to do prediction on a dataset without the target variable?
You can use the
newdataargument for this, i.e.See the help page for more information.
On a separate note, I recommend switching to mlr3, the successor of mlr.