Interface ITreeBasedClassifier<T>
- Namespace
- AiDotNet.Interfaces
- Assembly
- AiDotNet.dll
Interface for tree-based classification algorithms.
public interface 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).
- Inherited Members
- Extension Methods
Remarks
Tree-based classifiers make decisions by learning a series of hierarchical rules from data. They are highly interpretable and can capture non-linear relationships between features.
For Beginners: Decision trees work like a flowchart - they ask a series of yes/no questions about features to reach a decision. For example, to classify if an animal is a cat: "Has fur?" (yes) -> "Has whiskers?" (yes) -> "Meows?" (yes) -> "It's a cat!"
Key properties:
- MaxDepth: How deep the tree can go (more depth = more complex decisions)
- Feature importance: Which features were most useful for classification
Properties
FeatureImportances
Gets the feature importance scores computed during training.
Vector<T>? FeatureImportances { get; }
Property Value
- Vector<T>
A vector of importance scores, one for each feature. Higher values indicate more important features. Returns null if the model has not been trained.
Remarks
Feature importance is typically computed based on how much each feature contributes to reducing impurity (e.g., Gini impurity or entropy) in the tree.
For Beginners: This tells you which features the tree found most useful for making decisions. A high importance score means that feature appears often near the top of the tree and is crucial for classification.
LeafCount
Gets the number of leaf nodes in the tree.
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.
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.
int NodeCount { get; }
Property Value
- int
The count of non-terminal nodes that make decisions. Returns 0 if the model has not been trained.