README.md in xgb-0.1.2 vs README.md in xgb-0.1.3

- old
+ new

@@ -6,36 +6,47 @@ [![Build Status](https://travis-ci.org/ankane/xgb.svg?branch=master)](https://travis-ci.org/ankane/xgb) ## Installation -First, [install XGBoost](https://xgboost.readthedocs.io/en/latest/build.html). On Mac, copy `lib/libxgboost.dylib` to `/usr/local/lib`. +First, [install XGBoost](https://xgboost.readthedocs.io/en/latest/build.html). For Homebrew, use: +```sh +brew install xgboost +``` + Add this line to your application’s Gemfile: ```ruby gem 'xgb' ``` ## Getting Started -This library follows the [Python API](https://xgboost.readthedocs.io/en/latest/python/python_api.html). Some methods and options are missing at the moment. PRs welcome! +This library follows the [Python API](https://xgboost.readthedocs.io/en/latest/python/python_api.html), with the `get_` and `set_` prefixes removed from methods. Some methods and options are missing at the moment. PRs welcome! ## Learning API +Prep your data + +```ruby +x = [[1, 2], [3, 4], [5, 6], [7, 8]] +y = [1, 2, 3, 4] +``` + Train a model ```ruby params = {objective: "reg:squarederror"} -dtrain = Xgb::DMatrix.new(x_train, label: y_train) +dtrain = Xgb::DMatrix.new(x, label: y) booster = Xgb.train(params, dtrain) ``` Predict ```ruby -dtest = Xgb::DMatrix.new(x_test) +dtest = Xgb::DMatrix.new(x) booster.predict(dtest) ``` Save the model to a file @@ -135,10 +146,28 @@ ```ruby Numo::DFloat.new(3, 2).seq ``` +## XGBoost Installation + +There’s an experimental branch that includes XGBoost with the gem for easiest installation. + +```ruby +gem 'xgb', github: 'ankane/xgb', branch: 'vendor', submodules: true +``` + +Please file an issue if it doesn’t work for you. + +You can also specify the path to XGBoost in an initializer: + +```ruby +Xgb.ffi_lib << "/path/to/xgboost/lib/libxgboost.so" +``` + +> Use `libxgboost.dylib` for Mac and `xgboost.dll` for Windows + ## Helpful Resources - [Parameters](https://xgboost.readthedocs.io/en/latest/parameter.html) - [Parameter Tuning](https://xgboost.readthedocs.io/en/latest/tutorials/param_tuning.html) @@ -147,10 +176,10 @@ - [LightGBM](https://github.com/ankane/lightgbm) - LightGBM for Ruby - [Eps](https://github.com/ankane/eps) - Machine Learning for Ruby ## Credits -Thanks to the [xgboost](https://github.com/PairOnAir/xgboost-ruby) gem for serving as an initial reference, and Selva Prabhakaran for the [test datasets](https://github.com/selva86/datasets). +Thanks to the [xgboost](https://github.com/PairOnAir/xgboost-ruby) gem for serving as an initial reference. ## History View the [changelog](https://github.com/ankane/xgb/blob/master/CHANGELOG.md)