{"id":13879406,"url":"https://github.com/ankane/lightgbm-ruby","last_synced_at":"2025-11-17T14:11:46.122Z","repository":{"id":56881186,"uuid":"202269423","full_name":"ankane/lightgbm-ruby","owner":"ankane","description":"High performance gradient boosting for Ruby","archived":false,"fork":false,"pushed_at":"2025-09-20T01:33:23.000Z","size":3876,"stargazers_count":83,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-03T15:15:09.324Z","etag":null,"topics":["lightgbm","machine-learning","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/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-14T03:42:26.000Z","updated_at":"2025-10-30T04:56:09.000Z","dependencies_parsed_at":"2025-01-15T21:09:35.659Z","dependency_job_id":"a6b57c53-cd9e-4635-b85c-2341531f0388","html_url":"https://github.com/ankane/lightgbm-ruby","commit_stats":{"total_commits":349,"total_committers":2,"mean_commits":174.5,"dds":0.002865329512893977,"last_synced_commit":"33f0369fffc57391aabc25a8837e15e23446b4f9"},"previous_names":["ankane/lightgbm-ruby","ruby-ml/lightgbm-ruby","ankane/lightgbm"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/ankane/lightgbm-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Flightgbm-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Flightgbm-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Flightgbm-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Flightgbm-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/lightgbm-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Flightgbm-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283418035,"owners_count":26832617,"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-11-08T02:00:06.281Z","response_time":57,"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":["lightgbm","machine-learning","rubyml"],"created_at":"2024-08-06T08:02:19.943Z","updated_at":"2025-11-17T14:11:46.107Z","avatar_url":"https://github.com/ankane.png","language":"Ruby","readme":"# LightGBM Ruby\n\n[LightGBM](https://github.com/microsoft/LightGBM) - high performance gradient boosting - for Ruby\n\n[![Build Status](https://github.com/ankane/lightgbm-ruby/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/lightgbm-ruby/actions)\n\n## Installation\n\nAdd this line to your application’s Gemfile:\n\n```ruby\ngem \"lightgbm\"\n```\n\nOn Mac, also install OpenMP:\n\n```sh\nbrew install libomp\n```\n\n## Training 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: \"regression\"}\ntrain_set = LightGBM::Dataset.new(x, label: y)\nbooster = LightGBM.train(params, train_set)\n```\n\nPredict\n\n```ruby\nbooster.predict(x)\n```\n\nSave the model to a file\n\n```ruby\nbooster.save_model(\"model.txt\")\n```\n\nLoad the model from a file\n\n```ruby\nbooster = LightGBM::Booster.new(model_file: \"model.txt\")\n```\n\nGet the importance of features\n\n```ruby\nbooster.feature_importance\n```\n\nEarly stopping\n\n```ruby\nLightGBM.train(params, train_set, valid_sets: [train_set, test_set], early_stopping_rounds: 5)\n```\n\nCV\n\n```ruby\nLightGBM.cv(params, train_set, nfold: 5, verbose_eval: true)\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 = LightGBM::Regressor.new\nmodel.fit(x, y)\n```\n\n\u003e For classification, use `LightGBM::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.txt\")\n```\n\nLoad the model from a file\n\n```ruby\nmodel.load_model(\"model.txt\")\n```\n\nGet the importance of features\n\n```ruby\nmodel.feature_importances\n```\n\nEarly stopping\n\n```ruby\nmodel.fit(x, y, eval_set: [[x_test, y_test]], early_stopping_rounds: 5)\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://lightgbm.readthedocs.io/en/latest/Parameters.html)\n- [Parameter Tuning](https://lightgbm.readthedocs.io/en/latest/Parameters-Tuning.html)\n\n## Related Projects\n\n- [XGBoost](https://github.com/ankane/xgboost-ruby) - XGBoost for Ruby\n- [Eps](https://github.com/ankane/eps) - Machine learning for Ruby\n\n## Credits\n\nThis library follows the [Python API](https://lightgbm.readthedocs.io/en/latest/Python-API.html). A few differences are:\n\n- The `get_` and `set_` prefixes are removed from methods\n- The default verbosity is `-1`\n- With the `cv` method, `stratified` is set to `false`\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/lightgbm-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/lightgbm-ruby/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/lightgbm-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/lightgbm-ruby.git\ncd lightgbm-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%2Flightgbm-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Flightgbm-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Flightgbm-ruby/lists"}