CatBoost Rust Package
Cargo Package
Cargo package can be found here
Historical Context
- This started off as an attempt to publish the catboost bindings to cargo
- Eventually decided to unofficially split out the code and maintain separate rust bindings, similar to
onnxruntime-rs - Note that this is voluntarily maintained and not yet endorsed by the official catboost team
Differences versus official rust package
- Necessary changes made to publish crate instead of referencing the git repo, which is pretty big
- The official
catboost-sysone attempts to rebuild the shared library, whereas this one downloads it from the github release page. - The
build.rsscript is with assumptionlibcatboostshared library already downloaded separately. - Also marked the Model as
Sendso that it can be used across threads, due to the documentation stating it's thread safe. Note that this is not yet extensively tested though. - As of the present the catboost version is hardcoded, it is currently 1.0.6.
If you need dependencies for bindgen
apt-get install -y curl build-essential pkg-config libssl-dev libclang-dev clang cmake
Install libcatboost
- Download catboost binary from
https://github.com/catboost/catboost/releases/tag/v1.0.6.- If you are using Linux, download
libcatboostmodel.so - If you are using MacOS, download
libcatboostmodel.dylib - Place the file in
/usr/lib/ - Create a soft link to
x.x.1, e.g.sudo ln -s libcatboostmodel.so libcatboostmodel.so.1
- If you are using Linux, download
Basic usage example
- Add a dependency to your Cargo.toml:
[dependencies]
catboost-rs = "0.1.6"
- To use catboost, it assumes the shared libraries are available. You will need to download the shared library from the official releases page. If you are using linux, download
libcatboostmodel.so. If you are using Mac, downloadlibcatboostmodel.dylib. As of the present, only version 1.0.6 is supported. - Move these libraries to
/usr/lib - Now you can apply pretrained model in your code:
// Bring catboost module into the scope
use catboost_rs as catboost;
Documentation
Run cargo doc --open in catboost/rust-package directory.
Tests
Run cargo test in catboost/rust-package directory.