LightGBM Rust binding

Overview

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.

Comments
  • adding integration with polars

    adding integration with polars

    Hi,

    First off I've been playing around with the crate and I think it's really great.

    One thing that I thought might be useful is to have integration with polars (i.e. something like pandas integration with sklearn in python)

    I've added a new constructor method from_dataframe for the Dataset struct and packaged it under a new crate feature dataframe

    I'm not sure if you're accepting contributions and whether a contribution like this would be something you'd want. Feel free to close the pr if not.

    Let me know what you think!

    Thanks :)

    opened by benjaminjellis 4
  • Add linter CI and refactoring

    Add linter CI and refactoring

    • Add CI to run clippy and format checking.
    • Fixes all clippy warning.
      • Removes unused imports.
      • Removes primitive casting.
      • Removes unnecessary wrapping results and ?.
    • Format examples.
    • Shorten some if expressions.
    • Uses new to construct LGBMError.
    opened by paq 4
  • Support Windows

    Support Windows

    Fixes build script to support building on windows platform.

    With this change, I have confirmed that examples work at the minimum on Windows. But, my testing is seriously lacking, so it may not works perfectly.

    opened by paq 4
  • Avoid redundant prefixes

    Avoid redundant prefixes

    • Renames LGBMError to Error and LGBMResult to Result.
      • See details https://doc.rust-lang.org/1.0.0/style/style/naming/README.html#avoid-redundant-prefixes-[rfc-356]
    • Changes booster::save_file return value to Result for avoiding panic.
    opened by paq 1
  • We need to specify the c++11 version explicitly in our build

    We need to specify the c++11 version explicitly in our build

    It will be really helpful for us, if we could add a line in here:

    https://github.com/vaaaaanquish/lightgbm-rs/blob/main/lightgbm-sys/build.rs#L39-L43

        let dst = Config::new(&lgbm_root)
            .profile("Release")
            .uses_cxx11()
            .cxxflag("-std=c++11") // this is the line we need to add
            .define("BUILD_STATIC_LIB", "ON")
            .build();
    
    opened by Adam57 0
  • Added support for weights

    Added support for weights

    Hi there!

    I just added support to assign weights to observation since I needed it for a project. Just a wrapper for LGBM_DatasetSetField. Hope it is useful to someone else.

    Cheers.

    opened by geohardtke 0
  • add load_string and save_string apis.

    add load_string and save_string apis.

    The in-memory equivalents of load_file and save_file.

    Maybe loading from a &[u8] and saving to a Vec would be better to avoid the conversions between c-strings and rust-strings. Or maybe that could be a future api (load_vec, save_vec). Thoughts?

    opened by leofidus 0
  • GPU support

    GPU support

    Error { desc: "GPU Tree Learner was not enabled in this build.\nPlease recompile with CMake option -DUSE_GPU=1" }

    May I ask, is there any plan to support GPU, the current version does not support GPU, there will be the above error

    opened by momodi 0
Releases(v0.2.4)
Owner
vaaaaanquish
Darth Vader
vaaaaanquish
Rust binding of primitiv

Rust frontend of primitiv Prerequisites Rust (1.26 or later) Clang (3.9 or later) (optional) CUDA (8.0 or later) Install mkdir work cd work # build p

primitiv 19 Nov 22, 2021
Rust binding to LuisaCompute (WIP)

luisa-compute-rs Rust binding to LuisaCompute (WIP) Inside this crate: An almost safe binding to LuisaCompute An EDSL for writing kernels A new backen

Luisa Group 14 Jan 5, 2023
Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Aviram Hassan 139 Dec 30, 2022
Practice repo for learning Rust. Currently going through "Rust for JavaScript Developers" course.

rust-practice ?? Practice repo for learning Rust. Directories /rust-for-js-dev Files directed towards "Rust for JavaScript Developers" course. Thank y

Sammy Samkough 0 Dec 25, 2021
A Rust library with homemade machine learning models to classify the MNIST dataset. Built in an attempt to get familiar with advanced Rust concepts.

mnist-classifier Ideas UPDATED: Finish CLI Flags Parallelize conputationally intensive functions Class-based naive bayes README Image parsing Confusio

Neil Kaushikkar 0 Sep 2, 2021
🦀Rust Turkiye - Rust Dersleri

Rust Turkiye - Rust Dersleri CURIOSITY - Featuring Richard Feynman Bu repo Rust Turkiye tarafindan duzenlenen Rust Dersleri egitiminin alistirma ve ko

Theo M. Bulut 12 Jan 14, 2023
A Rust machine learning framework.

Linfa linfa (Italian) / sap (English): The vital circulating fluid of a plant. linfa aims to provide a comprehensive toolkit to build Machine Learning

Rust-ML 2.2k Jan 2, 2023
Machine Learning library for Rust

rusty-machine This library is no longer actively maintained. The crate is currently on version 0.5.4. Read the API Documentation to learn more. And he

James Lucas 1.2k Dec 31, 2022
Rust library for Self Organising Maps (SOM).

RusticSOM Rust library for Self Organising Maps (SOM). Using this Crate Add rusticsom as a dependency in Cargo.toml [dependencies] rusticsom = "1.1.0"

Avinash Shenoy 26 Oct 17, 2022
Rust language bindings for TensorFlow

TensorFlow Rust provides idiomatic Rust language bindings for TensorFlow. Notice: This project is still under active development and not guaranteed to

null 4.1k Jan 1, 2023
Machine learning crate for Rust

rustlearn A machine learning package for Rust. For full usage details, see the API documentation. Introduction This crate contains reasonably effectiv

Maciej Kula 547 Dec 28, 2022
Rust bindings for the C++ api of PyTorch.

tch-rs Rust bindings for the C++ api of PyTorch. The goal of the tch crate is to provide some thin wrappers around the C++ PyTorch api (a.k.a. libtorc

Laurent Mazare 2.3k Jan 1, 2023
个人的 rust 学习资料

?? 通知: 项目文档迁移到: https://github.com/higker/learn-rust learning-rust-zh 个人的 rust 学习资料 学习目录 目录 源代码地址 相关解析 第一个rust程序 https://github.com/higker/learning-ru

Jarvib Ding 16 Jun 21, 2022
Distributed compute platform implemented in Rust, and powered by Apache Arrow.

Ballista: Distributed Compute Platform Overview Ballista is a distributed compute platform primarily implemented in Rust, powered by Apache Arrow. It

Ballista 2.3k Jan 3, 2023
Tensors and differentiable operations (like TensorFlow) in Rust

autograd Differentiable operations and tensors backed by ndarray. Motivation Machine learning is one of the field where Rust lagging behind other lang

Ryo ASAKURA 403 Dec 25, 2022
Rust numeric library with R, MATLAB & Python syntax

Peroxide Rust numeric library contains linear algebra, numerical analysis, statistics and machine learning tools with R, MATLAB, Python like macros. W

Tae Geun Kim 351 Dec 29, 2022
A fast, safe and easy to use reinforcement learning framework in Rust.

RSRL (api) Reinforcement learning should be fast, safe and easy to use. Overview rsrl provides generic constructs for reinforcement learning (RL) expe

Thomas Spooner 139 Dec 13, 2022
Neural networks in Rust

deeplearn-rs Deep learning in Rust! This is my first shot at this. It's mostly just a proof of concept right now. The API will change. Status We have

Theodore DeRego 199 Oct 23, 2022
A deep learning library for rust

Alumina An experimental deep learning library written in pure rust. Breakage expected on each release in the short term. See mnist.rs in examples or R

zza 95 Nov 30, 2022