Online LightGBM

Machine Learning
Introduced by
Ke et al. (LightGBM); Bifet, Gavalda (online boosting theory)
Year
2017 (LightGBM); 2000s (online boosting)
Type
Online ensemble (incremental gradient boosting)
Family
Machine learning

What does it do?

Online LightGBM applies the Light Gradient-Boosting Machine framework to data that arrives over time.

Rather than training once on a complete dataset, the model is updated batch by batch: new boosting trees are fitted to the new observations and appended to the existing ensemble. This allows LightGBM's histogram-based boosting to be used in streaming and continual-learning settings without rebuilding the model from scratch.

The intuition behind the method

Standard LightGBM reads the full dataset, builds histograms of feature values, and grows trees in rounds. Online LightGBM keeps the model that has already been trained and, when new labelled observations arrive, adds trees fitted to the gradients those observations produce under the current model. Earlier trees are kept, and the ensemble grows by accumulating corrections for the new data. The process is comparable to adding new material to an existing course rather than teaching the whole course again each time.

History

LightGBM was introduced by Ke et al. at NeurIPS 2017; its histogram-based binning and leaf-wise tree growth were presented as ways to speed up gradient boosting decision trees. The batch-append procedure described on this page is an implementation pattern built on that framework; the cited LightGBM paper does not define it. The drift-adaptation literature cited here, Bifet and Gavaldà (2009) on adaptive learning from evolving data streams, is background on handling changing distributions and does not define the incremental boosting procedure.

When to use it

Use Online LightGBM when data arrives continuously or in regular batches, and when retraining the full model on all history is too slow or too costly for the application. Typical cases include fraud detection, clickstream modelling, IoT sensor prediction and recommendation pipelines that must follow changing user behaviour. It fits best when new labelled data accumulates regularly and the target relationship changes gradually. Do not use it when the data-generating process changes abruptly, because the existing trees are never reweighted or removed and may then mislead; full retraining or a drift-gated reset is more appropriate. Do not use it for a static dataset that fits in memory, where standard LightGBM is simpler to tune and to validate.

Limitations and considerations

  • The ensemble is never pruned, so the number of trees grows with every update, which increases inference latency and memory use over time.
  • Gradient estimates from small mini-batches are noisy, so updates can be unstable when batches are too small to represent the current data.
  • Because old trees keep their weights, a sharp change in the target function can leave the ensemble dominated by trees that no longer fit the data.
  • The method has no built-in detection of distribution shift and no mechanism that deliberately down-weights or removes outdated trees.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Existing trees are preserved during an update, so a new batch adds corrections without discarding what the ensemble has already learned.
  • Each update fits new trees only to the new batch's gradients, so histogram construction scales with batch size rather than with the full history, although scoring the batch still traverses the existing ensemble.
  • Each update needs only the new mini-batch's data rather than the full data history, although the existing ensemble must also be kept in memory.
  • Inherits LightGBM's histogram-based splitting and leaf-wise growth, which keep the work on each batch efficient.
  • Supports categorical features through LightGBM's built-in handling, which reduces the preprocessing needed before each update.

Applications

  • Real-time fraud detection systems that must adapt to changing fraud patterns.
  • Clickstream and ad-click prediction pipelines that process large volumes of events.
  • IoT and sensor data modelling where device behaviour drifts over time.
  • Recommender systems that incorporate new user interactions between full retraining runs.
  • Financial forecasting where market conditions shift gradually.

How it works

How it works

1

An initial LightGBM model is trained on the first available batch of data, giving a base ensemble that captures patterns in that seed dataset. The model can also start with no trees and grow entirely through successive incremental updates.

2

When new labelled data arrives from a stream, a sensor feed, a periodic data dump or another rolling source, it is collected into a mini-batch. Batch size is a trade-off: smaller batches reflect recent data more quickly but give noisier gradient estimates, while larger batches give more stable estimates but respond more slowly.

3

The current ensemble scores each new observation, and the gradient of the loss with respect to the current prediction is computed for each one. These gradients identify where the existing ensemble still misfits the new data, and the new trees are fitted to them.

Formula
g_i = \partial L(y_i, \hat{y}_i)/\partial \hat{y}_i
4

New histogram-based trees are fitted to these gradients using LightGBM's leaf-wise growth and its GOSS and EFB optimisations. Only the new mini-batch is binned into histograms, so histogram construction depends on batch size rather than on the full history. Scoring the batch through the existing ensemble, however, grows with the number of trees, so the cost of an update rises as the ensemble grows.

5

The new trees are appended to the existing ensemble and scaled by the configured learning rate, which limits how much each tree changes the prediction. Earlier trees keep their fitted values. The updated model is then available for inference on new observations.

Formula
\hat{y}_i \leftarrow \hat{y}_i + \eta \cdot f_t(x_i)

Common pitfalls

  • Assuming the model handles concept drift automatically. It does not, so pair it with a drift detector such as ADWIN, DDM or Page-Hinkley when drift is expected.
  • Using a large learning rate for later batches. Each new batch's trees then drive the predictions strongly toward recent data, which can dominate the older ensemble.
  • Ignoring that the ensemble grows with each update. Prediction latency rises with tree count, so latency-critical deployments need periodic distillation, pruning or a tree cap.
  • Evaluating only on the most recent batch, which can hide degradation on older segments of the data distribution.

Frequently asked questions

How is Online LightGBM different from running LightGBM again on all the data?

Running LightGBM from scratch discards the previous model and rebuilds it from all available data, which can be costly as data grows. Online LightGBM starts from the current ensemble and adds trees fitted to the new batch only. Each update's cost depends on batch size and also grows with the number of trees already in the ensemble, because the new batch must be scored through every existing tree to compute gradients.

How should I handle concept drift?

LightGBM has no built-in drift detection. Pair the model with a statistical detector such as ADWIN, DDM or Page-Hinkley. When drift is flagged, the usual options are to discard the ensemble and retrain on recent data, or to start a new ensemble. Shrinkage only scales the trees added after it is set; it does not down-weight trees already in the ensemble, so it is not a way to forget older data.

How large should each mini-batch be?

There is no universal rule. Larger batches give more stable gradient estimates and smoother updates but respond more slowly to change, while smaller batches adapt faster at the cost of more variance. Choose a size that contains enough examples of each class, including minority classes, to estimate gradients reliably, and check the choice on held-out data.

Will the model keep growing indefinitely?

Yes, unless it is actively controlled. Each update adds trees and none are removed. Options include capping the total number of trees and retraining from scratch when the cap is reached, or compressing the current ensemble with knowledge distillation.

Can Online LightGBM be used for regression as well as classification?

It supports the objectives available in standard LightGBM, including binary and multiclass classification and regression. Ranking objectives also need group information for each batch, so batch construction must respect query groups; verify this against the implementation you use.

How should I evaluate an Online LightGBM model?

Evaluate on data the model has not yet trained on. Prequential (test-then-train) evaluation scores each incoming batch with the current model before using that batch for training, which gives an error curve over time. Also report performance per data segment or time window, because a good overall average can hide degradation on older or minority segments. Learning rate, mini-batch size and the tree-count limit are tuned hyperparameters: choose them on validation data drawn from the stream rather than relying on a universal default value.

Related methods

Sources

  1. Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., Ye, Q., & Liu, T.-Y. (2017). LightGBM: A Highly Efficient Gradient Boosting Decision Tree. Advances in Neural Information Processing Systems, 30.

    Open publication reference
  2. Bifet, A., & Gavalda, R. (2009). Adaptive Learning from Evolving Data Streams. Advances in Intelligent Data Analysis VIII. Lecture Notes in Computer Science, vol 5772. Springer.

    Open DOI reference