Expand description
Decision tree algorithms and ensemble methods.
This module implements:
- CART (Classification and Regression Trees) using Gini impurity
- Random Forest ensemble classifier
- Gradient Boosting Machine (GBM) for sequential ensemble learning
§Example
ⓘ
// Full API example (not yet implemented)
use aprender::prelude::*;
use aprender::tree::DecisionTreeClassifier;
// Training data (simple 2D binary classification)
let x = Matrix::from_vec(4, 2, vec![
0.0, 0.0, // class 0
0.0, 1.0, // class 1
1.0, 0.0, // class 1
1.0, 1.0, // class 0
]).expect("Matrix creation should succeed in tests");
let y = vec![0, 1, 1, 0];
// Train decision tree
let mut tree = DecisionTreeClassifier::new()
.with_max_depth(3);
tree.fit(&x, &y).expect("fit should succeed");
// Make predictions
let predictions = tree.predict(&x);Structs§
- Decision
Tree Classifier - Decision tree classifier using the CART algorithm.
- Decision
Tree Regressor - Decision tree regressor using the CART algorithm.
- Gradient
Boosting Classifier - Gradient Boosting Classifier.
- Leaf
- Leaf node in a decision tree.
- Node
- Internal node in a decision tree.
- Random
Forest Classifier - Random Forest classifier - an ensemble of decision trees.
- Random
Forest Regressor - Random Forest Regressor.
- Regression
Leaf - Leaf node in a regression tree.
- Regression
Node - Internal node in a regression tree.
Enums§
- Regression
Tree Node - A node in a regression tree (either internal node or leaf).
- Tree
Node - A node in a decision tree (either internal node or leaf).