{"id":13416437,"url":"https://github.com/ankane/xgboost-ruby","last_synced_at":"2026-01-11T21:57:46.356Z","repository":{"id":56898715,"uuid":"202525164","full_name":"ankane/xgboost-ruby","owner":"ankane","description":"High performance gradient boosting for Ruby","archived":false,"fork":false,"pushed_at":"2025-12-27T16:08:15.000Z","size":306,"stargazers_count":118,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-27T22:54:05.587Z","etag":null,"topics":["machine-learning","rubyml","xgboost"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-08-15T10:56:06.000Z","updated_at":"2025-12-27T16:08:19.000Z","dependencies_parsed_at":"2024-11-14T01:01:02.433Z","dependency_job_id":"af83e69e-76fa-4309-b051-833111b30893","html_url":"https://github.com/ankane/xgboost-ruby","commit_stats":{"total_commits":223,"total_committers":3,"mean_commits":74.33333333333333,"dds":0.452914798206278,"last_synced_commit":"7f5358fa4307197b46c6c26d3a36ab0bc1575032"},"previous_names":["ankane/xgboost-ruby","ruby-ml/xgboost-ruby","ankane/xgb","ankane/xgboost"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/xgboost-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fxgboost-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fxgboost-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fxgboost-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fxgboost-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/xgboost-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fxgboost-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28140775,"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","status":"online","status_checked_at":"2025-12-31T02:00:06.200Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["machine-learning","rubyml","xgboost"],"created_at":"2024-07-30T21:00:58.839Z","updated_at":"2026-01-11T21:57:46.337Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","readme":"# XGBoost Ruby\n\n[XGBoost](https://github.com/dmlc/xgboost) - high performance gradient boosting - for Ruby\n\n[![Build Status](https://github.com/ankane/xgboost-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/xgboost-ruby/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"xgb\"\n```\n\nOn Mac, also install OpenMP:\n\n```sh\nbrew install libomp\n```\n\n## Learning API\n\nPrep your data\n\n```ruby\nx = [[1, 2], [3, 4], [5, 6], [7, 8]]\ny = [1, 2, 3, 4]\n```\n\nTrain a model\n\n```ruby\nparams = {objective: \"reg:squarederror\"}\ndtrain = XGBoost::DMatrix.new(x, label: y)\nbooster = XGBoost.train(params, dtrain)\n```\n\nPredict\n\n```ruby\ndtest = XGBoost::DMatrix.new(x)\nbooster.predict(dtest)\n```\n\nSave the model to a file\n\n```ruby\nbooster.save_model(\"model.json\")\n```\n\nLoad the model from a file\n\n```ruby\nbooster = XGBoost::Booster.new(model_file: \"model.json\")\n```\n\nGet the importance of features\n\n```ruby\nbooster.score\n```\n\nEarly stopping\n\n```ruby\nXGBoost.train(params, dtrain, evals: [[dtrain, \"train\"], [dtest, \"eval\"]], early_stopping_rounds: 5)\n```\n\nCV\n\n```ruby\nXGBoost.cv(params, dtrain, nfold: 3, verbose_eval: true)\n```\n\nSet metadata about a model\n\n```ruby\nbooster[\"key\"] = \"value\"\nbooster.attributes\n```\n\n## Scikit-Learn API\n\nPrep your data\n\n```ruby\nx = [[1, 2], [3, 4], [5, 6], [7, 8]]\ny = [1, 2, 3, 4]\n```\n\nTrain a model\n\n```ruby\nmodel = XGBoost::Regressor.new\nmodel.fit(x, y)\n```\n\n\u003e For classification, use `XGBoost::Classifier`\n\nPredict\n\n```ruby\nmodel.predict(x)\n```\n\n\u003e For classification, use `predict_proba` for probabilities\n\nSave the model to a file\n\n```ruby\nmodel.save_model(\"model.json\")\n```\n\nLoad the model from a file\n\n```ruby\nmodel.load_model(\"model.json\")\n```\n\nGet the importance of features\n\n```ruby\nmodel.feature_importances\n```\n\nEarly stopping\n\n```ruby\nmodel = XGBoost::Regressor.new(early_stopping_rounds: 5)\nmodel.fit(x, y, eval_set: [[x_test, y_test]])\n```\n\n## Data\n\nData can be an array of arrays\n\n```ruby\n[[1, 2, 3], [4, 5, 6]]\n```\n\nOr a Numo array\n\n```ruby\nNumo::NArray.cast([[1, 2, 3], [4, 5, 6]])\n```\n\nOr a Rover data frame\n\n```ruby\nRover.read_csv(\"houses.csv\")\n```\n\nOr a Daru data frame\n\n```ruby\nDaru::DataFrame.from_csv(\"houses.csv\")\n```\n\n## Helpful Resources\n\n- [Parameters](https://xgboost.readthedocs.io/en/latest/parameter.html)\n- [Parameter Tuning](https://xgboost.readthedocs.io/en/latest/tutorials/param_tuning.html)\n\n## Related Projects\n\n- [LightGBM](https://github.com/ankane/lightgbm) - LightGBM for Ruby\n- [Eps](https://github.com/ankane/eps) - Machine learning for Ruby\n\n## Credits\n\nThis library follows the [Python API](https://xgboost.readthedocs.io/en/latest/python/python_api.html), with the `get_` and `set_` prefixes removed from methods to make it more Ruby-like.\n\nThanks to the [xgboost](https://github.com/PairOnAir/xgboost-ruby) gem for showing how to use FFI.\n\n## History\n\nView the [changelog](https://github.com/ankane/xgboost-ruby/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/xgboost-ruby/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/xgboost-ruby/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n\nTo get started with development:\n\n```sh\ngit clone https://github.com/ankane/xgboost-ruby.git\ncd xgboost-ruby\nbundle install\nbundle exec rake vendor:all\nbundle exec rake test\n```\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fxgboost-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fxgboost-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fxgboost-ruby/lists"}