r - Get accuracy for a boosted multinomial model -


i trying find accuracy of boosted model. code such:

wine.boost = gbm(as.factor(wine) ~ alcohol+hue, data = italiantrain, distribution = "multinomial", n.trees = 5000 , interaction.depth = 2)  wine.boost.testpredict = predict(wine.boost, newdata=italiantest,  n.trees =5000, type = "response")  confusionmatrix(wine.boost.testpredict, italiantrain$wine) 

when try following error:

error in confusionmatrix.default(wine.boost.trainpredict, italiantest$wine):  data cannot have more levels reference 

i'm not sure correct or i'm doing wrong. suggestions?

the best way comfortable data not @ it:

> iris.boost = gbm(species ~ ., data = iris, +                  distribution = "multinomial", n.trees = 5000 , interaction.depth = 2) >  > iris.boost.testpredict = predict(iris.boost, newdata=iris[1:3, 1:4],  +                                  n.trees =5000, type = "response") > iris.boost.testpredict , , 5000          setosa   versicolor    virginica [1,] 0.9987619 0.0011808413 5.722106e-05 [2,] 0.9994021 0.0004801001 1.177551e-04 [3,] 0.9993529 0.0005547632 9.236662e-05 

you have convert basic gbm output factor (or use train, you).


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -