Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for GBM regression #19

Open
jsuchal opened this issue Jan 1, 2020 · 5 comments
Open

Support for GBM regression #19

jsuchal opened this issue Jan 1, 2020 · 5 comments

Comments

@jsuchal
Copy link

jsuchal commented Jan 1, 2020

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!

@jsuchal jsuchal changed the title Support fro GBM regression Support for GBM regression Jan 2, 2020
@asafschers
Copy link
Owner

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!

@jsuchal
Copy link
Author

jsuchal commented Feb 13, 2020

@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)

models.zip

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)

@jsuchal
Copy link
Author

jsuchal commented Mar 4, 2020

Btw this seems to work find in master. Any chance for a version bump on rubygems?

@jsuchal
Copy link
Author

jsuchal commented Mar 4, 2020

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?

@caioeps
Copy link

caioeps commented Jan 6, 2022

Btw this seems to work find in master. Any chance for a version bump on rubygems?

+1 on this, @asafschers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants