问题描述
有一个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评估引擎如库)。
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.GBMConverter
),并从那里
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;
}
您可以在GBM数据结构,从研发使用的protobuf导出到C ++转换应用数据格式(如由RProtoBuf包实现)。再次,请参阅JPMML-转换器库是怎么做的。
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.
这篇关于部署GBM模型C ++ |获得Predict.gbm工作的R之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!