Ruby scoring API for Predictive Model Markup Language (PMML).
Currently supports -
- Decision Tree
- Naive Bayes
- Logistic Regression
- Random Forest
- Gradient Boosted Trees
Will be happy to implement new models by demand, or assist with any other issue.
Contact me here or at aschers@gmail.com.
Tutorial - Deploy Machine Learning Models from R Research to Ruby Production with PMML
Add this line to your application's Gemfile:
gem 'scoruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install scoruby
naive_bayes = Scoruby.load_model 'naive_bayes.pmml'
features = { f1: v1 , ... }
naive_bayes.lvalues(features)
naive_bayes.score(features, 'l1')
logistic_regression = Scoruby.load_model 'logistic_regression.pmml'
features = { f1: v1 , ... }
logistic_regression.score(features)
decision_tree = Scoruby.load_model 'decision_tree.pmml'
features = { f1 : v1, ... }
decision_tree.decide(features)
=> #<Decision:0x007fc232384180 @score="0", @score_distribution={"0"=>"0.999615579933873", "1"=>"0.000384420066126561"}>
random_forest = Scoruby.load_model 'titanic_rf.pmml'
features = {
Sex: 'male',
Parch: 0,
Age: 30,
Fare: 9.6875,
Pclass: 2,
SibSp: 0,
Embarked: 'Q'
}
random_forest.score(features)
=> {:label=>"0", :score=>0.882}
random_forest.decisions_count(features)
=> {"0"=>441, "1"=>59}
gbm = Scoruby.load_model 'gbm.pmml'
features = {
Sex: 'male',
Parch: 0,
Age: 30,
Fare: 9.6875,
Pclass: 2,
SibSp: 0,
Embarked: 'Q'
}
gbm.score(features)
=> 0.3652639329522468
After checking out the repo, run bin/setup
to install dependencies. Then, run rake rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/asafschers/scoruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.