0
fit <- gbm(Crop_Damage ~ Estimated_Insects_Count+Crop_Type+ Soil_Type
       +Pesticide_Use_Category+Number_Doses_Week+Number_Weeks_Used
       +Number_Weeks_Quit+Season,
       data = mydata, distribution="multinomial")

gbmpred <- predict(fit,mydata,n.trees = fit$n.trees)

I tried above code but it gives me probabilities.I want to get predictions

HubertL
  • 19,246
  • 3
  • 32
  • 51
  • 2
    Please provide a minimal, complete, and reproducible example that anyone else can simply copy and paste into their R session to run. All library statements and inputs need to be included. Cut down your data to the minimum needed to illustrate the problem and if your input is `x` then show it by displaying the output of `dput(x)` in your question. See http://stackoverflow.com/help/mcve for general advice and see http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for more R oriented advice on how to ask a question on SO. – G. Grothendieck Jan 29 '16 at 20:41
  • please provide reproducible code (including some dataset) – HubertL Jan 29 '16 at 20:41

1 Answers1

0

By default the predictions of the predict function are in the scale of f(x), hence in the returned values for the multinomial (classification) case will return the probabilities. All you have to do is to translate them to responses by taking the class that has the highest probability

George Sotiropoulos
  • 1,864
  • 1
  • 22
  • 32