Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up`predict` fails if formula method is used with deleted variables #574
Comments
|
I'm not sure the workaround is correct. According to http://stats.stackexchange.com/a/112052/130941 |
|
The issue is that an extra column is coming along for the ride ( I'll make a fix for the issue. |
|
This should work find in the devel version and also the one that I just sent to CRAN. |
In a multi-class classification problem, trying to get the class probabilities from a model object trained with the formula method with deleted variables (i.e.
-variable) fails withpredictwhennewdatais not specified.Reproducible example:
then
predict(fit.lda, type = "prob")fails with:
If the
-Petal.Lengthis omitted in thetrainformula, there is no error.This error occurs for some models (
lda,knn,svmRadial,mlpML) but not others (nnet,rf,xgbTree).=====
Workaround
If
newdatais specified with the training data, it seems to succeed in retrieving the class probabilities. Is this the correct way of doing it?In the documentation for
predict:In the past, I always omitted
newdatafor obtaining information from the trained model, and included the parameter when using on new testing data.