在C ++中部署GBM模型|获取Predict.gbm在R之外工作 [英] Deploy GBM Model in C++ | Get Predict.gbm to work outside of R

查看:281
本文介绍了在C ++中部署GBM模型|获取Predict.gbm在R之外工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将gbm模型导出到C ++。具体来说,如何调用predict.gbm函数在R之外运行,以对新数据集进行评分。

Is there a way to export a gbm model to C++. Specifically, how do I invoke the predict.gbm function to run outside of R in order to score new datasets.

我已将模型导出为PMML文件,但我不确定新数据集如何基于PMML得分。

I have exported the model as a PMML file but I am unsure as to how new datasets will be scores based off the PMML.

我是R的新人,花了很多时间试图找出没有效果,并会欣赏任何潜在客户

I am new to R and have spent a lot of hours trying to figure this out to no avail and will appreciate any leads

提前感谢

推荐答案

这里,PMML只能帮助你,如果你有一个基于C ++的PMML评估引擎可用或者,您可以使用C ++调用基于Java的PMML评估引擎,例如 JPMML-Evaluator 库)。

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

您可以将GBM模型翻译为C ++源代码,稍后再本机运行它。翻译并不困难,因为GBM成员决策树可以编码为简单的if-else语句。您可以在 JPMML-Converter 库(类 org)中看到它是如何实现的

You could translate GBM model to C++ source code and run it "natively" later on. The translation is not difficult, because GBM member decision trees can be encoded as simple if-else statements. You can see how it's implemented in the JPMML-Converter library (class org.jpmml.converter.GBMConverter) and take it from there.

翻译成PMML:

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

翻译为C / C ++ / C#:

Translation to C/C++/C#:

if($predicate){
   return $score;
}

您可以使用ProtoBuf将GBM数据结构从R导出到C ++转换应用程序数据格式(由RProtoBuf软件包实现)。再次,请看看JPMML-Converter库如何做。

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

这篇关于在C ++中部署GBM模型|获取Predict.gbm在R之外工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆