GBM multinomial distribution, how to use predict() to get predicted class?

拟墨画扇 提交于 2019-12-01 03:46:22

Take a look at ?predict.gbm, you'll see that there is a "type" parameter to the function. Try out predict(<gbm object>, <new data>, type="response").

smci

predict.gbm(..., type='response') is not implemented for multinomial, or indeed any distribution other than bernoulli or poisson.

So you have to find the most likely class (apply(.., 1, which.max) on the vector output from prediction), as desertnaut wrote:

preds = predict(your_model, n.trees, newdata=...,type='response')

pred_class <- apply(preds, 1, which.max)

Just write a wrapper which accepts type='response' and returns this when it's a multinomial model.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!