Xgb

XGBoost - the high performance machine learning library - for Ruby

:fire: Uses the C API for blazing performance

Installation

First, install XGBoost. On Mac, copy lib/libxgboost.dylib to /usr/local/lib.

Add this line to your application’s Gemfile:

gem 'xgb'

Getting Started

Train a model

params = {objective: "reg:squarederror"}
train_set = Xgb::DMatrix.new(x_train, label: y_train)
booster = Xgb.train(params, train_set)

Predict

booster.predict(x_test)

Save the model to a file

booster.save_model("model.txt")

Load the model from a file

booster = Xgb::Booster.new(model_file: "model.txt")

Reference

This library follows the Core Data Structure and Learning APIs for the Python library. Some methods and options are missing at the moment. PRs welcome!

Helpful Resources

  • LightGBM - LightGBM for Ruby
  • Eps - Machine Learning for Ruby

Credits

Thanks to the xgboost gem for serving as an initial reference, and Selva Prabhakaran for the test datasets.

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help: