I am trying to build simple multi-class logistic regression models using glmnet in R. However when I try to predict the test data and obtain contingency table I get an error. A sample session is reproduced below.
> mat = matrix(1:100,nrow=10)
> test = matrix(1:50,nrow=5)
> classes <- as.factor(11:20)
> model <- glmnet(mat, classes, family="multinomial", alpha=1)
> pred <- predict(model, test)
> table(pred, as.factor(11:15))
Error in table(pred, as.factor(11:15)) :
all arguments must have the same length
Any help will be appreciated. R noob here.
Thanks.
?predict.glmnetcarefully, paying particular attention to the argumentstypeands. - jorantypeargument expects a character, as intype = "class". Second, thesargument is very clearly documented, and necessary for what you are attempting. There's even an example illustrating its use. - jorantypeargument correctly, but was not supplyings. Thanks for pointing it out. If you want to post your comment as an answer, I can accept it. - user721975