As I was trying to predict using Logistic Regression model in R, I am having the following error:
Error
pred <- predict(model,newdata=test)
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : factor admission_type_id has new levels 8
From my understanding, the testing data of the column "admission_type_id" has new levels compared training data. I tried looking at the unique values and I see that Train data has all the values of Test data.
unique(train$admission_type_id)
1 1 3 2 6 5 8 4
Levels: 1 2 3 4 5 6 7 8unique(test$admission_type_id)
1 6 1 2 3 5 8
Levels: 1 2 3 4 5 6 7 8
It would be of great help if some one can help me understand the issue. Thank you.