Module rustlearn::trees::decision_tree [] [src]

A two-class decision tree classifer.

This model implements the CART (Classification and Regression Trees) algorithm for both dense and sparse data. The tree is split by randomly sampling max_features candidate features, then choosing the best split amongst those features using reduction in Gini impurity.

Both binary and numeric features are supported; categorical features without a clear ordering should be one-hot encoded for best results.

The model is specified using hyperparameters


Fitting the model on the iris dataset is straightforward:

use rustlearn::prelude::*;
use rustlearn::trees::decision_tree::Hyperparameters;
use rustlearn::datasets::iris;

let (X, y) = iris::load_data();

let mut model = Hyperparameters::new(4)
                                .one_vs_rest();, &y).unwrap();

let prediction = model.predict(&X).unwrap();



A two-class decision tree.


Hyperparameters for a DecisionTree model.