Module rustlearn::ensemble::random_forest [] [src]

Random forests.

Fits a forest of decision trees using bootstrap samples of training data. The predictions of individual trees are averaged to arrive at the final prediction. This counters the tendency of individual trees to overfit and provides better out-of-sample predictions. In general, the more trees fit, the higher the accuracy.

Examples

use rustlearn::prelude::*;

use rustlearn::ensemble::random_forest::Hyperparameters;
use rustlearn::datasets::iris;
use rustlearn::trees::decision_tree;

let (data, target) = iris::load_data();

let mut tree_params = decision_tree::Hyperparameters::new(data.cols());
tree_params.min_samples_split(10)
    .max_features(4);

let mut model = Hyperparameters::new(tree_params, 10)
    .one_vs_rest();

model.fit(&data, &target).unwrap();

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

Structs

Hyperparameters
RandomForest