Cross check in R

I have a problem of cross-checking a dataset in R.

mypredict.rpart <- function(object, newdata){ predict(object, newdata, type = "class") } res <- errorest(win~., data=df, model = rpart, predict = mypredict.rpart) 

I get this error.

Error in .rpart view (object, newdata, type = "class"): Invalid prediction for rpart object

My data set is made up of 16 numeric attributes, and the win has two coefficients 0 and 1. You can download the data set at the link

+6
source share
1 answer

If you are doing a classification, win should be a factor.

 df$win = factor(df$win) 

Then your code works for me:

 > res Call: errorest.data.frame(formula = win ~ ., data = df, model = rpart, predict = mypredict.rpart) 10-fold cross-validation estimator of misclassification error Misclassification error: 0.4844 
+9
source

Source: https://habr.com/ru/post/903141/


All Articles