Table of Contents

Class AdaBoostClassifier<T>

Namespace
AiDotNet.Classification.Ensemble
Assembly
AiDotNet.dll

AdaBoost (Adaptive Boosting) classifier that combines weak learners.

public class AdaBoostClassifier<T> : EnsembleClassifierBase<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

T

The numeric data type used for calculations (e.g., float, double).

Inheritance
AdaBoostClassifier<T>
Implements
IFullModel<T, Matrix<T>, Vector<T>>
IModel<Matrix<T>, Vector<T>, ModelMetadata<T>>
IParameterizable<T, Matrix<T>, Vector<T>>
ICloneable<IFullModel<T, Matrix<T>, Vector<T>>>
IGradientComputable<T, Matrix<T>, Vector<T>>
Inherited Members
Extension Methods

Remarks

AdaBoost iteratively trains weak classifiers on re-weighted versions of the data, where incorrectly classified samples receive higher weights in subsequent iterations. The final prediction is a weighted vote of all weak learners.

For Beginners: AdaBoost works like a learning system that focuses on its mistakes:

  1. Train a simple classifier on the data
  2. See which samples were misclassified
  3. Give those samples higher importance
  4. Train another classifier with the new importance weights
  5. Repeat many times
  6. Combine all classifiers with voting

This creates a powerful classifier from many weak ones.

Constructors

AdaBoostClassifier(AdaBoostClassifierOptions<T>?, IRegularization<T, Matrix<T>, Vector<T>>?)

Initializes a new instance of the AdaBoostClassifier class.

public AdaBoostClassifier(AdaBoostClassifierOptions<T>? options = null, IRegularization<T, Matrix<T>, Vector<T>>? regularization = null)

Parameters

options AdaBoostClassifierOptions<T>

Configuration options for AdaBoost.

regularization IRegularization<T, Matrix<T>, Vector<T>>

Optional regularization strategy.

Properties

Options

Gets the AdaBoost specific options.

protected AdaBoostClassifierOptions<T> Options { get; }

Property Value

AdaBoostClassifierOptions<T>

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

ModelType

Predict(Matrix<T>)

Predicts class labels for the given input data by taking the argmax of probabilities.

public override Vector<T> Predict(Matrix<T> input)

Parameters

input Matrix<T>

The input features matrix where each row is an example and each column is a feature.

Returns

Vector<T>

A vector of predicted class indices for each input example.

Remarks

This implementation uses the argmax of the probability distribution to determine the predicted class. For binary classification with a custom decision threshold, you may want to use PredictProbabilities() directly and apply your own threshold.

For Beginners: This method picks the class with the highest probability for each sample.

For example, if the probabilities are [0.1, 0.7, 0.2] for classes [A, B, C], this method returns class B (index 1) because it has the highest probability (0.7).

PredictProbabilities(Matrix<T>)

Aggregates predictions from all estimators in the ensemble.

public override Matrix<T> PredictProbabilities(Matrix<T> input)

Parameters

input Matrix<T>

The input features matrix.

Returns

Matrix<T>

A matrix of aggregated class probabilities.

Remarks

Default implementation averages the probability predictions from all estimators. Derived classes may override this for different aggregation strategies.

Train(Matrix<T>, Vector<T>)

Trains the AdaBoost classifier on the provided data.

public override void Train(Matrix<T> x, Vector<T> y)

Parameters

x Matrix<T>
y Vector<T>