Deploying a GBM Model in C ++ | Get Predict.gbm to work outside R

Is there a way to export the gbm model in C ++. In particular, how do I call expect.gbm to run outside of R to clog new datasets.

I exported the model as a PMML file, but I'm not sure how the new datasets will be evaluated based on PMML.

I am new to R and spent many hours trying to figure it out to no avail and would appreciate any links

Thank you in advance

0
source share
1 answer

Here PMML helps you only if you have a C ++-based PMML evaluation engine (alternatively, you can use C ++ to invoke a Java-based PMML evaluation engine such as JPMML-Evaluator ).

You can translate the GBM model into C ++ source code and run it โ€œnativelyโ€ later. Translation is not difficult because GBM decision trees can be encoded as simple if-else statements. You can see how it is implemented in the JPMML-Converter library (class org.jpmml.converter.GBMConverter ) and from there from there.

Translation in PMML:

 Node node = new Node() .withPredicate($predicate) .withScore($score); 

Translation in C / C ++ / C #:

 if($predicate){ return $score; } 

You can export a GBM data structure from an R to C ++ conversion application using the ProtoBuf data format (as implemented by the RProtoBuf package). Again, see how the JPMML-Converter library does this.

0
source

Source: https://habr.com/ru/post/987987/


All Articles