windows 10 rstudio 1.01.136 i have been trying to build model to classify customers which are going to default or not
prediction_test <- predict(train.tree,newdata = test ,type = "class")
I'm getting the following error
Error in eval(expr, envir, enclos) : object 'Workclass.dummy' not found
so please can anyone tell me how can i remove this error
the variable workclass has only 5 values namely
as.matrix(prop.table(table(train$Workclass)))
[,1]
Federal-gov 0.02948
Never-worked 0.00021
others 0.13885
Private 0.75342
Self-emp-not-inc 0.07804
as I combined others having less proportion into others
to make it more clear I used decision tree
library(rpart)
set.seed(333)
train.tree <- rpart(Income.Group~.,data = train,method = "class",
control= rpart.control(minsplit = 20,minbucket = 100,maxdepth = 10),
xval = 5)
I previously got the error
factor Workclass has new levels Local-gov, Self-emp-inc, State-gov, Without-pay
which I corrected by removing variable ID from test data