ExtraTreesClassifier<T>

Models & Types · AiDotNet.Classification.Ensemble

Extra Trees (Extremely Randomized Trees) classifier.

Inheritance: ClassifierBase<T> → ProbabilisticClassifierBase<T> → EnsembleClassifierBase<T> → ExtraTreesClassifier<T>

Implements: ITreeBasedClassifier<T>

For Beginners

Extra Trees takes randomization even further than Random Forest:

Random Forest: “Look at random features, pick the BEST split” Extra Trees: “Look at random features, pick a RANDOM split”

Benefits of Extra Trees:

  • Faster training (no need to find optimal splits)
  • Often better generalization
  • More robust to noise

When Extra Trees might be better:

  • When you have noisy data
  • When Random Forest overfits
  • When you need faster training

How It Works

Extra Trees is an ensemble method that builds multiple decision trees with extra randomization. Unlike Random Forest which finds the best split among random features, Extra Trees picks random splits, leading to more diversity.

Example

var newSample = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var labels = new Vector<double>(new double[] { 0.0, 1.0, 0.0, 1.0 });
var features = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
// Use AiModelBuilder facade for Extra Trees classification
var builder = new AiModelBuilder<double, Matrix<double>, Vector<double>>()
    .ConfigureModel(new ExtraTreesClassifier<double>(
        new ExtraTreesClassifierOptions<double>()));
            
var result = builder.Build(features, labels);
var prediction = result.Predict(newSample);

Constructors

Constructor Summary
ExtraTreesClassifier(ExtraTreesClassifierOptions<T> options, IRegularization<T, Matrix<T>, Vector<T>> regularization) Initializes a new instance of the ExtraTreesClassifier class.

Properties

Property Summary
int LeafCount { get; }
int MaxDepth { get; }
int NodeCount { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
void Train(Matrix<T> x, Vector<T> y) Returns the model type identifier for this classifier.