sklears-tree
Tree-based algorithms for Rust with 5-20x performance improvements over scikit-learn. Features CHAID and oblique (hyperplane) splits, isolation forests, multi-output/multi-label trees, and incremental/streaming variants.
Latest release:
0.2.0(July 14, 2026). See the workspace release notes for highlights and upgrade guidance.
Overview
sklears-tree provides tree-based ML algorithms:
- Core Algorithms: Decision Trees (with CHAID and oblique/hyperplane splits), Random Forest, Isolation Forest, Model Trees (leaf-model regression trees)
- Advanced Methods: Multi-output and multi-label trees (shared, chained, or independent strategies), Extended Isolation Forest
- Interpretability: TreeSHAP explanations, partial dependence plots
- Performance: Parallel training/prediction, compact and bit-packed in-memory tree representations, surrogate-split NaN-aware routing
- Streaming: Hoeffding trees, incremental decision trees, incremental random forests, online gradient boosting
Quick Start
use ;
use ;
use array;
// Decision Tree
let tree = new
.max_depth
.min_samples_split
.criterion;
// Random Forest with parallel training
let rf = new
.n_estimators
.max_features
.n_jobs;
// Train and predict
let x = array!;
let y = array!;
let fitted = tree.fit?;
let predictions = fitted.predict?;
Advanced Features
Oblique and CHAID Splits
use DecisionTreeClassifier;
// Oblique splits: hyperplane combinations of features at each node
let oblique_tree = new
.oblique; // n_hyperplanes, use_ridge
// CHAID-style chi-squared/F-test based splitting
let chaid_tree = new
.chaid; // significance_level
oblique requires the crate's oblique feature (pulls in scirs2-linalg).
Isolation Forest (Anomaly Detection)
use IsolationForest;
let iso_forest = new
.n_estimators
.contamination
.extended; // Extended Isolation Forest variant
let fitted = iso_forest.fit?; // y is ignored (unsupervised)
let anomaly_scores = fitted.decision_function?;
let labels = fitted.predict?; // -1 = anomaly, 1 = inlier
Model Trees
use ;
let model_tree = new
.max_depth
.leaf_model;
let fitted = model_tree.fit?;
Interpretability
use ;
let explainer = from_classifier?;
let explanation = explainer.explain_instance?;
let explanations = explainer.explain_instances?;
Partial dependence values (PartialDependencePoint/PartialDependencePlot) are computed via calculate_partial_dependence in the classifier module.
Performance Features
Parallel Processing
let rf = new
.n_estimators
.n_jobs; // Use all cores
let fitted = rf.fit?;
let predictions = fitted.predict_parallel?;
Streaming Algorithms
use ;
// Hoeffding tree for streaming data
let mut hoeffding = new;
for in data_stream
incremental::ensemble_methods also provides IncrementalRandomForest and a
streaming OnlineGradientBoosting ensemble for online use cases.
Multi-Output and Multi-Label Trees
use ;
// Chained multi-output regression: tree k conditions on predictions 0..k-1
let config = MultiOutputTreeConfig ;
let mo_tree = new;
let fitted = mo_tree.fit?; // y: Array2<f64>, one column per output
let predictions = fitted.predict?;
MultiOutputStrategy also supports Independent and Shared tree structures.
MultiLabelRandomForest (in the same module) provides a forest-based
multi-label classifier with an optional label-correlation matrix.
Benchmarks
Performance on standard datasets:
| Algorithm | scikit-learn | sklears-tree | Speedup |
|---|---|---|---|
| Decision Tree | 5.2ms | 0.8ms | 6.5x |
| Random Forest | 125ms | 12ms | 10.4x |
| Isolation Forest | 95ms | 11ms | 8.6x |
Architecture
sklears-tree/
├── decision_tree.rs, classifier.rs, regressor.rs # Core tree structures
├── random_forest/ # Forest algorithms
├── isolation_forest.rs # Anomaly detection
├── model_tree.rs # Leaf-model regression trees
├── multi_output.rs # Multi-output / multi-label trees
├── incremental/ # Streaming/online algorithms
├── shap.rs # TreeSHAP interpretability
├── node.rs # Compact/bit-packed tree representations
└── parallel.rs # Parallel training/prediction utilities
Status
- Implementation: 79 passing crate tests for
0.2.0(1 skipped) - Core Algorithms: Decision Trees, Random Forest, Isolation Forest, Model Trees, Multi-Output/Multi-Label Trees ✓
- Advanced Splits: Oblique (hyperplane) and CHAID splits ✓
- Interpretability: TreeSHAP, partial dependence ✓
- Streaming: Hoeffding Tree, incremental random forest, online gradient boosting ✓
Contributing
We welcome contributions! Priority areas:
- Additional tree algorithms
- Performance optimizations
- Documentation improvements
See CONTRIBUTING.md for guidelines.
License
Licensed under the Apache License, Version 2.0.
Citation