8 releases

Uses old Rust 2015

0.2.3 Feb 11, 2021
0.2.2 Feb 2, 2021
0.2.1 Jan 31, 2021
0.1.3 Jan 21, 2021

#700 in Machine learning


Used in eorst

MIT license

4.5MB
81K SLoC

C++ 48K SLoC // 0.1% comments FORTRAN Legacy 23K SLoC // 0.4% comments C 3.5K SLoC // 0.4% comments CUDA 3.5K SLoC // 0.1% comments Python 1K SLoC // 0.2% comments Shell 529 SLoC // 0.1% comments Rust 438 SLoC // 0.0% comments Visual Studio Project 343 SLoC SWIG 341 SLoC // 0.3% comments Visual Studio Solution 32 SLoC JavaScript 1 SLoC Bitbake 1 SLoC

lightgbm-rs

LightGBM Rust binding

Require

You need an environment that can build LightGBM.

# linux
apt install -y cmake libclang-dev libc++-dev gcc-multilib

# OS X
brew install cmake libomp

On Windows

  1. Install CMake and VS Build Tools.
  2. Install LLVM and set an environment variable LIBCLANG_PATH to PATH_TO_LLVM_BINARY (example: C:\Program Files\LLVM\bin)

Please see below for details.

Usage

Example LightGBM train.

extern crate serde_json;
use lightgbm::{Dataset, Booster};
use serde_json::json;

let data = vec![vec![1.0, 0.1, 0.2, 0.1],
               vec![0.7, 0.4, 0.5, 0.1],
               vec![0.9, 0.8, 0.5, 0.1],
               vec![0.2, 0.2, 0.8, 0.7],
               vec![0.1, 0.7, 1.0, 0.9]];
let label = vec![0.0, 0.0, 0.0, 1.0, 1.0];
let dataset = Dataset::from_mat(data, label).unwrap();
let params = json!{
   {
        "num_iterations": 3,
        "objective": "binary",
        "metric": "auc"
    }
};
let bst = Booster::train(dataset, &params).unwrap();

Please see the ./examples for details.

example link
binary classification link
multiclass classification link
regression link

Develop

git clone --recursive https://github.com/vaaaaanquish/lightgbm-rs
docker build -t lgbmrs .
docker run -it -v $PWD:/app lgbmrs bash

# cargo build

Thanks

Much reference was made to implementation and documentation. Thanks.

Dependencies

~2.4–5MB
~101K SLoC