Hello everyone!
I got this message when I code a confusionMatrix: "Error in confusionMatrix.default(prediccion_1900, testing_1900$Genero) :
The data contain levels not found in the data."
str():
prediccion_1900 str() it´s a factor
testing_1900$Genero str() it´s a data.frame
in testing_1900$Genero , I TRIED many times to remove the separate symbol like this, but it does´t work....... ,sep = "([|])",remove = F
Please I´ll be very thankful with your help
Greetings!
Thanks a lot for your help, here´s the code:
testing_1900 = testing %>% filter(Id_usuario == 1900) %>%
select(Indice,Ano,Genero,Marca_temporal,Promedio_Idbm,Numero_Votos) %>%
mutate(Genero = factor(Genero))
testing_1900$Genero = fct_expand(testing_1900$Genero,levels(factor(testing$Genero))[2:20]) # More levels added to analize the error
set.seed(100)
prediccion_1900 = predict(modelo, newdata = testing_1900, type = "class") # type class so it doesn´t affect the number of levels less
confusionMatrix(prediccion_1900, testing_1900$Genero)