0

I've got a gbm object and I want to use it from C++. For example, use the predict.gbm() in C++ with new data. At first I tried to translate the if-else rule in C++ and just output the tree to a file. However, I found that the gbm result doesn't match the tree it generates. For example, when I use just the first tree, the SplitCodePred value in the tree doesn't match the value generated by predict.gbm(). So anybody knows how to do the prediction manually based on the gbm model?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Wei Li
  • 35
  • 5
  • Possible duplicate of [Extracting Model from GBM in R](http://stackoverflow.com/questions/36267304/extracting-model-from-gbm-in-r) – Andrew Mar 30 '16 at 22:49

1 Answers1

0

See my answer to your question on Cross Validated.

In short, you should be able to call e.g. gbm_pred directly from the C/C++ source. The source is available here. You can see how the gbm output object is mapped onto the arguments for gbm_pred in the R function predict.gbm.

Community
  • 1
  • 1
patr1ckm
  • 1,176
  • 9
  • 12