| Crates.io | linfa-ensemble |
| lib.rs | linfa-ensemble |
| version | 0.8.1 |
| created_at | 2025-09-30 09:51:36.027999+00 |
| updated_at | 2025-12-23 14:12:58.503846+00 |
| description | A general method for creating ensemble classifiers |
| homepage | |
| repository | https://github.com/rust-ml/linfa |
| max_upload_size | |
| id | 1860921 |
| size | 67,666 |
linfa-ensemble provides pure Rust implementations of Ensemble Learning algorithms for the Linfa toolkit.
linfa-ensemble is a crate in the linfa ecosystem, an effort to create a toolkit for classical Machine Learning implemented in pure Rust, akin to Python's scikit-learn.
linfa-ensemble currently provides an implementation of bootstrap aggregation (bagging) for other classifiers provided in linfa.
You can find examples in the examples/ directory. To run an bootstrap aggregation for ensemble of decision trees (a Random Forest) use:
$ cargo run --example ensemble_iris --release
The expected output should be
An example using Bagging with Decision Tree on Iris Dataset
Final Predictions:
[0, 2, 0, 1, 1, 2, 2, 1, 0, 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 1, 2, 2, 2, 0, 0, 1, 0, 2, 0], shape=[30], strides=[1], layout=CFcf (0xf), const ndim=1
classes | 0 | 1 | 2
0 | 11 | 0 | 0
1 | 0 | 7 | 1
2 | 0 | 1 | 10
Test accuracy: 93.333336
with default Decision Tree params,
Ensemble Size: 100,
Bootstrap Proportion: 0.7
Feature selection proportion: 1
An example using a Random Forest on Iris Dataset
Final Predictions:
[0, 1, 0, 1, 1, 2, 2, 1, 0, 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 1, 2, 2, 2, 0, 0, 1, 0, 2, 0], shape=[30], strides=[1], layout=CFcf (0xf), const ndim=1
classes | 0 | 1 | 2
0 | 11 | 0 | 0
1 | 0 | 8 | 0
2 | 0 | 1 | 10
Test accuracy: 96.666664
with default Decision Tree params,
Ensemble Size: 100,
Bootstrap Proportion: 0.7
Feature selection proportion: 0.2