README.md in lightgbm-0.1.0 vs README.md in lightgbm-0.1.1

- old
+ new

@@ -1,33 +1,81 @@ # LightGBM -LightGBM for Ruby +[LightGBM](https://github.com/microsoft/LightGBM) for Ruby +:fire: Uses the C API for blazing performance + +[![Build Status](https://travis-ci.org/ankane/lightgbm.svg?branch=master)](https://travis-ci.org/ankane/lightgbm) + ## Installation -First, [install LightGBM](https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html). +First, [install LightGBM](https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html). On Mac, copy `lib_lightgbm.so` to `/usr/local/lib`. Add this line to your application’s Gemfile: ```ruby gem 'lightgbm' ``` -Load a model +Train a model ```ruby -booster = LightGBM::Booster.new(model_file: "model.txt") +params = {objective: "regression"} +train_set = LightGBM::Dataset.new(x_train, label: y_train) +booster = LightGBM.train(params, train_set) ``` Predict ```ruby -booster.predict([[1, 2], [3, 4]]) +booster.predict(x_test) ``` +Save the model + +```ruby +booster.save_model("model.txt") +``` + +Load a model from a file + +```ruby +booster = LightGBM::Booster.new(model_file: "model.txt") +``` + +Get feature importance + +```ruby +booster.feature_importance +``` + +## Reference + +### Booster + +```ruby +booster = LightGBM::Booster.new(model_str: "tree...") +booster.to_json +booster.model_to_string +booster.current_iteration +``` + +### Dataset + +```ruby +dataset = LightGBM::Dataset.new(data, label: label, weight: weight, params: params) +dataset.num_data +dataset.num_feature + +# note: only works with unquoted CSVs +dataset = LightGBM::Dataset.new("data.csv", params: {headers: true, label: "name:label"}) +dataset.save_binary("train.bin") +dataset.dump_text("train.txt") +``` + ## Credits -Thanks to the [xgboost](https://github.com/PairOnAir/xgboost-ruby) gem for serving as an initial reference. +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). ## History View the [changelog](https://github.com/ankane/lightgbm/blob/master/CHANGELOG.md)