HoeffdingRaceRegressor¶
Hoeffding Race model selection for regression.
Uses the Hoeffding bound to progressively eliminate underperforming models with statistical confidence. All active models are trained on each observation. After each observation, models whose performance is statistically worse than the current best are eliminated from the race.
This is more efficient than greedy selection when there are many candidate models, because eliminated models no longer consume computation. It is more principled than successive halving because elimination is based on statistical evidence rather than a fixed schedule.
Parameters¶
-
models
Type →
listThe models to race against each other.
-
metric
Type →
metrics.base.RegressionMetric | NoneDefault →
NoneMetric used for comparing models. Defaults to
metrics.MAE. -
delta
Type →
floatDefault →
0.05Confidence parameter. Smaller values make elimination harder (more conservative). The algorithm is correct with probability at least
1 - delta. Defaults to 0.05. -
loss_range
Type →
floatDefault →
1.0The range of the per-observation loss values. For unbounded metrics you should set this to a reasonable upper bound. Defaults to 1.0.
Attributes¶
-
active_models
The models still in the race.
-
best_model
The current best model.
-
models
-
n_active_models
The number of models still in the race.
Examples¶
from river import datasets
from river import evaluate
from river import linear_model
from river import metrics
from river import model_selection
from river import optim
from river import preprocessing
models = [
linear_model.LinearRegression(optimizer=optim.SGD(lr=lr))
for lr in [1e-5, 1e-4, 1e-3, 1e-2]
]
dataset = datasets.TrumpApproval()
metric = metrics.MAE()
model = (
preprocessing.StandardScaler() |
model_selection.HoeffdingRaceRegressor(
models,
metric=metric,
delta=0.05,
loss_range=50.0,
)
)
evaluate.progressive_val_score(dataset, model, metric)
MAE: 1.319678
You can inspect how many models remain in the race:
model["HoeffdingRaceRegressor"].n_active_models
4
Methods¶
learn_one
Fits to a set of features x and a real-valued target y.
Parameters
- x —
dict[base.typing.FeatureName, Any] - y —
base.typing.RegTarget
predict_one
Predict the output of features x.
Parameters
- x
Returns
The prediction.