v2026.6.1
All Bundles
Bundle Core machine learning types: the seedable Random generator, Matrix2D linear algebra and activations, matrix reference holders, the NeuralNetwork and CSV-backed MatrixReader. Compile with -lib ml.

AdaBoost

Discrete AdaBoost over single-feature boolean decision stumps. Each round picks the stump (feature + polarity) with the lowest weighted error, gives it a vote of alpha = 0.5*ln((1-err)/err) and re-weights the samples to focus on mistakes; prediction is the sign of the weighted stump vote. Deterministic. Boosting stops early when no stump beats chance.

Example

# label (last column) = majority of three boolean features
booster := AdaBoost->New(16);
booster->Fit(data);
preds := booster->Predict(data);

Operations

Fit #

Fits the boosted ensemble. Each row is boolean features with the class label in the LAST column.

method : public : Fit(input:Bool[,]) ~ Bool

Parameters

NameTypeDescription
inputBooltraining matrix (features..., label) of Bool

Return

TypeDescription
Booltrue if fitting succeeded

GetLearnerCount #

Gets the number of boosting rounds actually used (early-stops when no stump beats chance or a stump is perfect).

method : public : GetLearnerCount() ~ Int

Return

TypeDescription
Intlearner count

IsFitted #

Whether the ensemble has been fitted.

method : public : IsFitted() ~ Bool

Return

TypeDescription
Booltrue if fitted

Load # function

Loads a fitted ensemble from a file.

function : Load(filename:String) ~ AdaBoost

Parameters

NameTypeDescription
filenameStringfile to load from

Return

TypeDescription
AdaBoostfitted ensemble, or Nil on failure

New # constructor

Constructor

New(num_learners:Int)

Parameters

NameTypeDescription
num_learnersIntmaximum number of boosting rounds

Predict #

Predicts class labels by the sign of the weighted stump vote.

method : public : Predict(input:Bool[,]) ~ Bool[]

Parameters

NameTypeDescription
inputBoolmatrix of feature rows (a trailing label column is ignored)

Return

TypeDescription
Boolper-row predicted classes, or Nil if not fitted

Score #

Computes classification accuracy on labeled data, comparing predictions against the class label in the LAST column.

method : public : Score(input:Bool[,]) ~ Float

Parameters

NameTypeDescription
inputBoollabeled matrix (features..., label) of Bool

Return

TypeDescription
Floatfraction of correctly classified rows, or 0.0 if not fitted

Store #

Saves the fitted ensemble to a file.

method : public : Store(filename:String) ~ Bool

Parameters

NameTypeDescription
filenameStringfile to store to

Return

TypeDescription
Booltrue if successful, false otherwise