scoruby
scoruby copied to clipboard
Support for GBM regression
I've learned a GBM regression tree model in R and tried loading it into ruby using scoruby and seems like it's not supported.
The r2pmml package produces a v4.3 .pmml that does not contain any OutputField
I only see.
<Targets>
<Target field="target" rescaleConstant="4.107037612571389"/>
</Targets>
The pmml package produces a v 4.4 pmml with something like this
<Output>
<OutputField name="Predicted_target" optype="continuous" dataType="double" feature="predictedValue"/>
<OutputField name="GaussianPrediction" feature="transformedValue" dataType="double">
<Apply function="+">
<FieldRef field="Predicted_target"/>
<Constant>4.10703761257139</Constant>
</Apply>
</OutputField>
</Output>
I've looked at the source of scoruby and seems like the logic for detecting gbm needs an OutputField. How can I help to add support for regression GBM?
Great work so far!
Hey Jano
Seems like Scoruby should support 4.3 GBM PMMLs that doesn't contain OutputField Please attach an example of the PMML that doesn't work for you so I can look into it
Thanks!
@asafschers sorry for the late reply. Here are two models learned in R, using standard gbm
message. First is exported to pmml using pmml
library, second using r2pmml
library. Both fail with RuntimeError (model not supported)
irb(main):003:0> m = Scoruby.load_model('out2.pmml')
Traceback (most recent call last):
7: from /home/johno/.rbenv/versions/2.6.5/bin/irb:23:in `<main>'
6: from /home/johno/.rbenv/versions/2.6.5/bin/irb:23:in `load'
5: from /home/johno/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
4: from (irb):3
3: from (irb):3:in `rescue in irb_binding'
2: from /home/johno/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/scoruby-0.3.3/lib/scoruby.rb:21:in `load_model'
1: from /home/johno/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/scoruby-0.3.3/lib/scoruby/model_factory.rb:21:in `factory_for'
RuntimeError (model not supported)
Pretty standard stuff in R e.g.
t = gbm(Sepal.Length ~ ., data = iris, verbose = TRUE, interaction.depth = 5, cv.folds = 5, train.fraction = 0.9, n.trees=50)
Btw this seems to work find in master. Any chance for a version bump on rubygems?
However this line looks extremely suspicious https://github.com/asafschers/scoruby/blob/master/lib/scoruby/models/gradient_boosted_model/model.rb#L23 for basic regression there should be no transformation. Is this for logistic regression only?
Btw this seems to work find in master. Any chance for a version bump on rubygems?
+1 on this, @asafschers.