README.md in lightgbm-0.1.2 vs README.md in lightgbm-0.1.3
- old
+ new
@@ -1,8 +1,8 @@
# LightGBM
-[LightGBM](https://github.com/microsoft/LightGBM) for Ruby
+[LightGBM](https://github.com/microsoft/LightGBM) - the high performance machine learning library - 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)
@@ -16,10 +16,20 @@
gem 'lightgbm'
```
## Getting Started
+This library follows the [Data Structure, Training, and Scikit-Learn APIs](https://lightgbm.readthedocs.io/en/latest/Python-API.html) of the Python library. A few differences are:
+
+- The `get_` prefix is removed from methods
+- The default verbosity is `-1`
+- With the `cv` method, `stratified` is set to `false`
+
+Some methods and options are also missing at the moment. PRs welcome!
+
+## Training API
+
Train a model
```ruby
params = {objective: "regression"}
train_set = LightGBM::Dataset.new(x_train, label: y_train)
@@ -42,40 +52,100 @@
```ruby
booster = LightGBM::Booster.new(model_file: "model.txt")
```
-Get feature importance
+Get the importance of features
```ruby
booster.feature_importance
```
-## Early Stopping
+Early stopping
```ruby
LightGBM.train(params, train_set, valid_set: [train_set, test_set], early_stopping_rounds: 5)
```
-## CV
+CV
```ruby
LightGBM.cv(params, train_set, nfold: 5, verbose_eval: true)
```
-## Reference
+## Scikit-Learn API
-This library follows the [Data Structure and Training APIs](https://lightgbm.readthedocs.io/en/latest/Python-API.html) for the Python library. A few differences are:
+Prep your data
-- The default verbosity is `-1`
-- With the `cv` method, `stratified` is set to `false`
+```ruby
+x = [[1, 2], [3, 4], [5, 6], [7, 8]]
+y = [1, 2, 3, 4]
+```
-Some methods and options are also missing at the moment. PRs welcome!
+Train a model
+```ruby
+model = LightGBM::Regressor.new
+model.fit(x, y)
+```
+
+> For classification, use `LightGBM::Classifier`
+
+Predict
+
+```ruby
+model.predict(x)
+```
+
+> For classification, use `predict_proba` for probabilities
+
+Save the model to a file
+
+```ruby
+model.save_model("model.txt")
+```
+
+Load the model from a file
+
+```ruby
+model.load_model("model.txt")
+```
+
+Get the importance of features
+
+```ruby
+model.feature_importances
+```
+
+## Data
+
+Data can be an array of arrays
+
+```ruby
+[[1, 2, 3], [4, 5, 6]]
+```
+
+Or a Daru data frame
+
+```ruby
+Daru::DataFrame.from_csv("houses.csv")
+```
+
+Or a Numo NArray
+
+```ruby
+Numo::DFloat.new(3, 2).seq
+```
+
## Helpful Resources
- [Parameters](https://lightgbm.readthedocs.io/en/latest/Parameters.html)
- [Parameter Tuning](https://lightgbm.readthedocs.io/en/latest/Parameters-Tuning.html)
+
+## Related Projects
+
+- [Xgb](https://github.com/ankane/xgb) - XGBoost 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).