Class ExtraTreesClassifier<T>
- Namespace
- AiDotNet.Classification.Ensemble
- Assembly
- AiDotNet.dll
Extra Trees (Extremely Randomized Trees) classifier.
public class ExtraTreesClassifier<T> : EnsembleClassifierBase<T>, ITreeBasedClassifier<T>, IProbabilisticClassifier<T>, IClassifier<T>, IFullModel<T, Matrix<T>, Vector<T>>, IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>, IModelSerializer, ICheckpointableModel, IParameterizable<T, Matrix<T>, Vector<T>>, IFeatureAware, IFeatureImportance<T>, ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>, IGradientComputable<T, Matrix<T>, Vector<T>>, IJitCompilable<T>
Type Parameters
TThe numeric data type used for calculations (e.g., float, double).
- Inheritance
-
ExtraTreesClassifier<T>
- Implements
-
IClassifier<T>
- Inherited Members
- Extension Methods
Remarks
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.
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
Constructors
ExtraTreesClassifier(ExtraTreesClassifierOptions<T>?, IRegularization<T, Matrix<T>, Vector<T>>?)
Initializes a new instance of the ExtraTreesClassifier class.
public ExtraTreesClassifier(ExtraTreesClassifierOptions<T>? options = null, IRegularization<T, Matrix<T>, Vector<T>>? regularization = null)
Parameters
optionsExtraTreesClassifierOptions<T>Configuration options for Extra Trees.
regularizationIRegularization<T, Matrix<T>, Vector<T>>Optional regularization strategy.
Properties
LeafCount
Gets the number of leaf nodes in the tree.
public int LeafCount { get; }
Property Value
- int
The count of terminal nodes (leaves) in the trained tree. Returns 0 if the model has not been trained.
MaxDepth
Gets the maximum depth of the tree.
public int MaxDepth { get; }
Property Value
- int
The maximum depth reached during training, or the configured maximum depth.
NodeCount
Gets the number of internal (decision) nodes in the tree.
public int NodeCount { get; }
Property Value
- int
The count of non-terminal nodes that make decisions. Returns 0 if the model has not been trained.
Options
Gets the Extra Trees specific options.
protected ExtraTreesClassifierOptions<T> Options { get; }
Property Value
Methods
Clone()
Creates a clone of the classifier model.
public override IFullModel<T, Matrix<T>, Vector<T>> Clone()
Returns
- IFullModel<T, Matrix<T>, Vector<T>>
A new instance of the model with the same parameters and options.
CreateNewInstance()
Creates a new instance of the same type as this classifier.
protected override IFullModel<T, Matrix<T>, Vector<T>> CreateNewInstance()
Returns
- IFullModel<T, Matrix<T>, Vector<T>>
A new instance of the same classifier type.
GetModelMetadata()
Gets metadata about the model.
public override ModelMetadata<T> GetModelMetadata()
Returns
- ModelMetadata<T>
A ModelMetadata object containing information about the model.
Remarks
This method returns metadata about the model, including its type, feature count, complexity, description, and additional information specific to classification.
For Beginners: Model metadata provides information about the model itself, rather than the predictions it makes. This includes details about the model's structure (like how many features it uses) and characteristics (like how many classes it can predict). This information can be useful for understanding and comparing different models.
GetModelType()
Returns the model type identifier for this classifier.
protected override ModelType GetModelType()
Returns
Train(Matrix<T>, Vector<T>)
Trains the Extra Trees classifier on the provided data.
public override void Train(Matrix<T> x, Vector<T> y)
Parameters
xMatrix<T>yVector<T>