
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
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.
pip install rustrees
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)
cargo add rustrees
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));
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
FAQs
Decision trees in Rust
We found that rustrees demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.