Skip to main content

Decision trees in Rust

Project description

Rustrees: Decision Trees & Random Forests in Rust with Python Bindings

Build Status PyPI version Rust Package Documentation License: MIT

Overview

Rustrees is an efficient decision tree and random forest library written in Rust with Python bindings. It aims to provide speed comparable to Sklearn with the reliability and performance of Rust.

Features

  • 🏎️ Speed: As fast as Sklearn on average.
  • 🔗 Python Bindings: Effortless integration with Python.
  • 🔒 Type Safety: Benefit from Rust's strong type system.

Python

Installation

pip install rustrees

Quick Start

from sklearn.metrics import accuracy_score
from sklearn import datasets
import rustrees.decision_tree as rt_dt

df = datasets.load_breast_cancer()

model = rt_dt.DecisionTreeClassifier(max_depth=5).fit(df["data"], df["target"])

acc = accuracy_score(df["target"], model.predict(df["data"]))

print("accuracy", acc)

Rust

Installation

cargo add rustrees

Quick Start

use rustrees::{DecisionTree, Dataset, r2};

let dataset = Dataset::read_csv("iris.csv", ",");

let dt = DecisionTree::train_reg(
   &dataset, 
   5,        // max_depth
   Some(1),  // min_samples_leaf        
   Some(42), // random_state
);

let pred = dt.predict(&dataset);

println!("r2 score: {}", r2(&dataset.target_vector, &pred));

Developing

First, create a virtualenv (this just needs to be done once):

python -m venv .env

Then, activate the virtualenv (needs to be done every time):

source .env/bin/activate

Now, install the requirements (just needs to be done once):

pip install -r requirements.txt

Finally, install the Python library at the local virtual environment with the following command (needs to be done every time you change the Rust code):

maturin develop --release

Now, you can import the library rustrees in Python. This can be done also from Jupyter notebooks. To do so, run the following command:

jupyter notebook

And then import the library in the notebook:

import rustrees.decision_tree as rt_dt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustrees-0.2.4.tar.gz (3.3 MB view hashes)

Uploaded Source

Built Distributions

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp312-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

rustrees-0.2.4-cp312-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.12 Windows x86

rustrees-0.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rustrees-0.2.4-cp312-cp312-macosx_10_12_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

rustrees-0.2.4-cp311-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

rustrees-0.2.4-cp311-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.11 Windows x86

rustrees-0.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rustrees-0.2.4-cp311-cp311-macosx_10_12_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

rustrees-0.2.4-cp310-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

rustrees-0.2.4-cp310-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.10 Windows x86

rustrees-0.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rustrees-0.2.4-cp310-cp310-macosx_10_12_x86_64.whl (2.1 MB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

rustrees-0.2.4-cp39-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

rustrees-0.2.4-cp39-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.9 Windows x86

rustrees-0.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp38-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

rustrees-0.2.4-cp38-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.8 Windows x86

rustrees-0.2.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

rustrees-0.2.4-cp37-none-win_amd64.whl (1.8 MB view hashes)

Uploaded CPython 3.7 Windows x86-64

rustrees-0.2.4-cp37-none-win32.whl (1.7 MB view hashes)

Uploaded CPython 3.7 Windows x86

rustrees-0.2.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

rustrees-0.2.4-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.6 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ s390x

rustrees-0.2.4-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (3.5 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ppc64le

rustrees-0.2.4-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARMv7l

rustrees-0.2.4-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

rustrees-0.2.4-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (3.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page