Module tree

Module tree 

Source
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§

DecisionTreeClassifier
Decision tree classifier using the CART algorithm.
DecisionTreeRegressor
Decision tree regressor using the CART algorithm.
GradientBoostingClassifier
Gradient Boosting Classifier.
Leaf
Leaf node in a decision tree.
Node
Internal node in a decision tree.
RandomForestClassifier
Random Forest classifier - an ensemble of decision trees.
RandomForestRegressor
Random Forest Regressor.
RegressionLeaf
Leaf node in a regression tree.
RegressionNode
Internal node in a regression tree.

Enums§

RegressionTreeNode
A node in a regression tree (either internal node or leaf).
TreeNode
A node in a decision tree (either internal node or leaf).