{"id":13747366,"url":"https://github.com/asafschers/scoruby","last_synced_at":"2025-04-09T22:18:19.526Z","repository":{"id":13079590,"uuid":"73565715","full_name":"asafschers/scoruby","owner":"asafschers","description":"Ruby Scoring API for PMML","archived":false,"fork":false,"pushed_at":"2022-10-19T04:55:03.000Z","size":2507,"stargazers_count":69,"open_issues_count":4,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T22:18:15.730Z","etag":null,"topics":["classification","decision-tree","gbm","gradient-boosted-models","gradient-boosting-classifier","machine-learning","naive-bayes","pmml","random-forest","ruby","ruby-gem","rubyml"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asafschers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-12T16:54:47.000Z","updated_at":"2025-03-11T01:20:29.000Z","dependencies_parsed_at":"2022-08-20T16:00:59.000Z","dependency_job_id":null,"html_url":"https://github.com/asafschers/scoruby","commit_stats":null,"previous_names":["asafschers/random_forester"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asafschers%2Fscoruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asafschers%2Fscoruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asafschers%2Fscoruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asafschers%2Fscoruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asafschers","download_url":"https://codeload.github.com/asafschers/scoruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119286,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classification","decision-tree","gbm","gradient-boosted-models","gradient-boosting-classifier","machine-learning","naive-bayes","pmml","random-forest","ruby","ruby-gem","rubyml"],"created_at":"2024-08-03T06:01:26.358Z","updated_at":"2025-04-09T22:18:19.489Z","avatar_url":"https://github.com/asafschers.png","language":"Ruby","funding_links":[],"categories":["Ruby","Machine Learning Libraries"],"sub_categories":["Frameworks","General-Purpose Machine Learning"],"readme":"\u003ca href=\"https://codeclimate.com/github/asafschers/scoruby\"\u003e\u003cimg src=\"https://codeclimate.com/github/asafschers/scoruby/badges/gpa.svg\" /\u003e\u003c/a\u003e\n[![Coverage Status](https://coveralls.io/repos/github/asafschers/scoruby/badge.svg?branch=master)](https://coveralls.io/github/asafschers/scoruby?branch=master)\n[![Gem Version](https://badge.fury.io/rb/scoruby.svg)](https://badge.fury.io/rb/scoruby)\n[![Build Status](https://travis-ci.org/asafschers/scoruby.svg?branch=master)](https://travis-ci.org/asafschers/scoruby)\n\n# Scoruby\n\nRuby scoring API for Predictive Model Markup Language (PMML).\n\nCurrently supports - \n\n* Decision Tree\n* Naive Bayes\n* Logistic Regression\n* Random Forest \n* Gradient Boosted Trees\n\nWill be happy to implement new models by demand, or assist with any other issue.\n\nContact me here or at aschers@gmail.com.\n\n[Tutorial - Deploy Machine Learning Models from R Research to Ruby Production with PMML](https://medium.com/@aschers/deploy-machine-learning-models-from-r-research-to-ruby-go-production-with-pmml-b41e79445d3d)\n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'scoruby'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install scoruby\n\n## Usage\n\n### Naive Bayes\n\n```ruby\nnaive_bayes = Scoruby.load_model 'naive_bayes.pmml'\nfeatures = { f1: v1 , ... } \nnaive_bayes.lvalues(features)\nnaive_bayes.score(features, 'l1')\n```\n\n### Logistic Regression\n\n```ruby\nlogistic_regression = Scoruby.load_model 'logistic_regression.pmml'\nfeatures = { f1: v1 , ... } \nlogistic_regression.score(features)\n```\n\n### Decision Tree\n\n```ruby\ndecision_tree = Scoruby.load_model 'decision_tree.pmml'\nfeatures = { f1 : v1, ... } \ndecision_tree.decide(features)\n\n=\u003e #\u003cDecision:0x007fc232384180 @score=\"0\", @score_distribution={\"0\"=\u003e\"0.999615579933873\", \"1\"=\u003e\"0.000384420066126561\"}\u003e\n```\n\n### Random Forest\n\n[Generate PMML - R](https://github.com/asafschers/scoruby/wiki/Random-Forest) \n\n```ruby\n\nrandom_forest = Scoruby.load_model 'titanic_rf.pmml'\nfeatures =  {\n        Sex: 'male',\n        Parch: 0,\n        Age: 30,\n        Fare: 9.6875,\n        Pclass: 2,\n        SibSp: 0,\n        Embarked: 'Q'       \n    }\n\nrandom_forest.score(features)\n\n=\u003e {:label=\u003e\"0\", :score=\u003e0.882}\n\nrandom_forest.decisions_count(features)\n\n=\u003e {\"0\"=\u003e441, \"1\"=\u003e59}\n\n```\n\n### Gradient Boosted model\n\n[Generate PMML - R](https://github.com/asafschers/scoruby/wiki/Gradient-Boosted-Model) \n\n```ruby\n\ngbm = Scoruby.load_model 'gbm.pmml'\n\nfeatures =  {\n        Sex: 'male',\n        Parch: 0,\n        Age: 30,\n        Fare: 9.6875,\n        Pclass: 2,\n        SibSp: 0,\n        Embarked: 'Q'       \n    }\n\ngbm.score(features)\n\n=\u003e 0.3652639329522468\n\n```\n\n## Development\n\nAfter 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.\n\nTo 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](https://rubygems.org).\n\n## Contributing\n\nBug 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](contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasafschers%2Fscoruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasafschers%2Fscoruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasafschers%2Fscoruby/lists"}