---
title: "Ensemble Learning in JavaScript with @kanaries/ml"
description: "Explore ensemble learning algorithms in JavaScript and TypeScript with @kanaries/ml, including Isolation Forest, AdaBoost, random forests, and bagging models."
canonical_url: "https://ml.kanaries.net/docs/apis/ensemble"
markdown_url: "https://ml.kanaries.net/docs/apis/ensemble/index.html.md"
---
# Ensemble Learning in JavaScript

## Module overview

The Ensemble module combines multiple weak learners to create stronger models for anomaly detection, classification, and regression. These algorithms are useful when single-model baselines are close to useful but need more robustness or more expressive decision behavior.

This module is a strong fit when:

- you need anomaly detection on tabular product or telemetry data
- a simple classifier or regressor underfits important patterns
- you want stronger performance without moving all the way to heavier model families

## JavaScript implementation

`@kanaries/ml` provides ensemble models in JavaScript and TypeScript so teams can run boosted learners and anomaly detection inside browser products and Node.js services. This is particularly helpful when feature generation, threshold logic, and downstream product actions already live in JS and should stay close to the model runtime.

If someone searches for "Isolation Forest in JavaScript" or "AdaBoost in TypeScript", this module is the right entry point.

## Quick navigation

- [Isolation Forest](/docs/apis/ensemble/iforest.md): anomaly detection for mostly-normal datasets with rare outliers
- [RandomForestClassifier](/docs/apis/ensemble/randomForestClassifier.md): majority-vote tree ensembles for classification
- [RandomForestRegressor](/docs/apis/ensemble/randomForestRegressor.md): averaged tree ensembles for regression
- [BaggingClassifier](/docs/apis/ensemble/baggingClassifier.md): bootstrap classifier ensembles with default or custom estimators
- [BaggingRegressor](/docs/apis/ensemble/baggingRegressor.md): bootstrap regression ensembles with default or custom estimators
- [ExtraTreesClassifier](/docs/apis/ensemble/extraTreesClassifier.md): extremely randomized trees for classification
- [ExtraTreesRegressor](/docs/apis/ensemble/extraTreesRegressor.md): extremely randomized trees for regression
- [AdaBoost Regressor](adaboost): boosted regression for non-linear tabular prediction
- [AdaBoost Classifier](/docs/apis/ensemble/adaboostClassifier.md): boosted classification for harder decision boundaries
- [GradientBoostingRegressor](/docs/apis/ensemble/gradientBoostingRegressor.md): squared-error gradient boosting for tabular regression
- [GradientBoostingClassifier](/docs/apis/ensemble/gradientBoostingClassifier.md): log-loss gradient boosting for binary and multiclass classification
- [XGBoostRegressor](/docs/apis/ensemble/xgboostRegressor.md): exact-greedy, regularized XGBoost regression
- [XGBoostClassifier](/docs/apis/ensemble/xgboostClassifier.md): exact-greedy, regularized XGBoost classification (binary and multiclass)

## Detailed module guide

### How to choose an algorithm

1. Use [Isolation Forest](/docs/apis/ensemble/iforest.md) when labels are unavailable and the main goal is outlier detection.
2. Use [RandomForestClassifier](/docs/apis/ensemble/randomForestClassifier.md) or [RandomForestRegressor](/docs/apis/ensemble/randomForestRegressor.md) when tree variance is high and nonlinear patterns matter.
3. Use [BaggingClassifier](/docs/apis/ensemble/baggingClassifier.md) when you want bootstrap aggregation around decision trees or a custom classifier.
4. Use [BaggingRegressor](/docs/apis/ensemble/baggingRegressor.md) when bootstrap averaging should reduce regression variance.
5. Use [ExtraTreesClassifier](/docs/apis/ensemble/extraTreesClassifier.md) or [ExtraTreesRegressor](/docs/apis/ensemble/extraTreesRegressor.md) for strongly randomized tree ensembles.
6. Use [AdaBoost Classifier](/docs/apis/ensemble/adaboostClassifier.md) when a simple classifier misses hard examples.
7. Use [AdaBoost Regressor](adaboost) when a single regressor is too weak for the target pattern.
8. Use [GradientBoostingClassifier](/docs/apis/ensemble/gradientBoostingClassifier.md) or [GradientBoostingRegressor](/docs/apis/ensemble/gradientBoostingRegressor.md) when you want stage-wise boosting with fine control over shrinkage and depth.
9. Use [XGBoostClassifier](/docs/apis/ensemble/xgboostClassifier.md) or [XGBoostRegressor](/docs/apis/ensemble/xgboostRegressor.md) when you want regularized, exact-greedy boosting close to the `xgboost` library.

### JavaScript deployment notes

- Treat thresholds, estimator counts, and learning rates as product-level tuning decisions.
- Ensemble models often provide a good middle ground between simple baselines and more operationally complex systems.
- In JS applications, keep feature extraction and prediction close together so model output can flow directly into business logic.
