AdaBoost Classifier
Learn what AdaBoost Classifier does, when to use it, and how to run AdaBoostClassifier in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
Algorithm overview
AdaBoostClassifier focuses on hard examples across rounds to improve classification performance over weak learners.
This algorithm is especially useful when:
- Baseline classifiers miss difficult boundary regions.
- You need improved recall/precision without switching to heavy models.
- You can invest in hyperparameter tuning for learning rate and rounds.
JavaScript implementation
@kanaries/ml exposes AdaBoost classification in JavaScript so you can build stronger tabular classifiers without leaving the browser or Node.js ecosystem. It is a good option when a single weak learner is too simple, but you still want a relatively compact model with straightforward prediction logic.
That makes it attractive for product-side decision systems and TypeScript services that need boosting behavior without operating a separate Python inference path.
Quick start
AdaBoostClassifier in Python vs JavaScript / TypeScript
If you searched for "AdaBoostClassifier in JavaScript" or "AdaBoostClassifier in TypeScript", this section maps the familiar scikit-learn call to the equivalent @kanaries/ml usage for browser and Node.js runtimes.
from sklearn.ensemble import AdaBoostClassifier
X = [[0, 0], [1, 1], [1, 0], [0, 1]]
y = [0, 1, 1, 0]
clf = AdaBoostClassifier(n_estimators=25, learning_rate=0.5, random_state=0)
clf.fit(X, y)
pred = clf.predict([[0.9, 0.8], [0.1, 0.2]])import { Ensemble } from '@kanaries/ml';
const X = [[0, 0], [1, 1], [1, 0], [0, 1]];
const y = [0, 1, 1, 0];
const clf = new Ensemble.AdaBoostClassifier({ nEstimators: 25, learningRate: 0.5 });
clf.fit(X, y);
const pred = clf.predict([[0.9, 0.8], [0.1, 0.2]]);Quick JavaScript example
import { Ensemble } from '@kanaries/ml';
const X = [[0, 0], [1, 1], [1, 0], [0, 1]];
const y = [0, 1, 1, 0];
const clf = new Ensemble.AdaBoostClassifier({ nEstimators: 25, learningRate: 0.5 });
clf.fit(X, y);
const pred = clf.predict([[0.9, 0.8], [0.1, 0.2]]);Detailed API reference
interface AdaBoostClassifierProps {
nEstimators?: number;
learningRate?: number;
randomState?: number;
}
constructor(props: AdaBoostClassifierProps = {})Parameters
| name | type | default | description |
|---|---|---|---|
| nEstimators | number | 50 | Number of boosting iterations |
| learningRate | number | 1.0 | Weight applied to each stump |
| randomState | number | undefined | Seed for reproducibility |
Algorithm
AdaBoostClassifier trains decision stumps sequentially and reweights samples so that misclassified points receive more focus in subsequent rounds. It selects the number of classes automatically:
- Binary (K = 2): discrete AdaBoost over polarity stumps with the one-sided SAMME weight update. Any two numeric labels are supported (they no longer have to be literal
0/1); classes are sorted numerically and predictions are mapped back to the original labels. - Multiclass (K > 2): SAMME (Zhu et al., 2009), sklearn's
AdaBoostClassifieralgorithm. The weak learner is a weighted-misclassification-optimal multiclass stump (each side predicts its weighted-majority class), a stump is accepted while its weighted error stays below1 - 1/K, andalpha = learning_rate * (log((1 - err) / err) + log(K - 1)). Misclassified samples are up-weighted byexp(alpha), andpredicttakes the argmax of the alpha-weighted votes.
Methods
fit(trainX: number[][], trainY: number[]): voidpredict(testX: number[][]): number[]predictProba(testX: number[][]): number[][]getFeatureImportances(): number[]
predictProba returns one column per class, ordered by the sorted class labels (for multiclass this is the normalized alpha-weighted vote share, a documented heuristic rather than a calibrated probability). getFeatureImportances covers both the binary and multiclass paths.
Implementation workflow
- Start with balanced preprocessing and clear label quality checks.
- Fit with several estimator counts and compare classification metrics.
- Tune threshold and class-weight strategy for product-specific tradeoffs.
JavaScript deployment notes
- Use AdaBoost when a simple linear or shallow-tree baseline is close to useful but misses harder examples.
- Monitor overfitting as you increase the number of estimators, especially on smaller datasets.
- It works best on structured tabular features rather than large-scale unstructured inputs.
BaggingClassifier
Train bootstrap classifier ensembles with the BaggingClassifier JavaScript and TypeScript implementation in @kanaries/ml.
AdaBoost Regressor
Learn what AdaBoost Regressor does, when to use it, and how to run AdaBoostRegressor in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.