Additional factor level in test data which causes no prediction

Hi,

How to handle a categorical variable having 3 levels in training data but with 4 levels in test data while predicting?
This is giving error while predicting…

Please advise.

Regards

Hi @manalykum.

If you are using R, simply add the 4th level to the training set manually using:

levels(trainSet)<-c(‘1’,‘2’,‘3’,‘4’)

1 Like