Skip to content

AMFRegressor

Aggregated Mondrian Forest regressor for online learning.

This algorithm is truly online, in the sense that a single pass is performed, and that predictions can be produced anytime.

Each node in a tree predicts according to the average of the labels it contains. The prediction for a sample is computed as the aggregated predictions of all the subtrees along the path leading to the leaf node containing the sample. The aggregation weights are exponential weights with learning rate step using a squared loss when use_aggregation is True.

This computation is performed exactly thanks to a context tree weighting algorithm. More details can be found in the original paper1.

The final predictions are the average of the predictions of each of the n_estimators trees in the forest.

Parameters

  • n_estimators

    Typeint

    Default10

    The number of trees in the forest.

  • step

    Typefloat

    Default1.0

    Step-size for the aggregation weights.

  • use_aggregation

    Typebool

    DefaultTrue

    Controls if aggregation is used in the trees. It is highly recommended to leave it as True.

  • seed

    Typeint

    DefaultNone

    Random seed for reproducibility.

Attributes

  • models

Examples

from river import datasets
from river import evaluate
from river import forest
from river import metrics

dataset = datasets.TrumpApproval()
model = forest.AMFRegressor(seed=42)
metric = metrics.MAE()

evaluate.progressive_val_score(dataset, model, metric)
MAE: 0.268533

Methods

learn_one

Fits to a set of features x and a real-valued target y.

Parameters

  • x
  • y

Returns

self

predict_one

Predict the output of features x.

Parameters

  • x

Returns

The prediction.


  1. Mourtada, J., Gaïffas, S., & Scornet, E. (2021). AMF: Aggregated Mondrian forests for online learning. Journal of the Royal Statistical Society Series B: Statistical Methodology, 83(3), 505-533.