DriftRetrainingClassifier¶
Drift retraining classifier.
This classifier is a wrapper for any classifier. It monitors the incoming data for concept drifts and warnings in the model's accurary. In case a warning is detected, a background model starts to train. If a drift is detected, the model will be replaced by the background model, and the background model will be reset.
Parameters¶
-
model
Type → base.Classifier
The classifier and background classifier class.
-
drift_detector
Type → base.DriftAndWarningDetector | base.BinaryDriftAndWarningDetector | None
Default →
None
Algorithm to track warnings and concept drifts. Attention! If the parameter train_in_background is True, the drift_detector must have a warning tracker.
-
train_in_background
Type → bool
Default →
True
Parameter to determine if a background model will be used.
Examples¶
from river import datasets
from river import evaluate
from river import drift
from river import metrics
from river import tree
dataset = datasets.Elec2().take(3000)
model = drift.DriftRetrainingClassifier(
model=tree.HoeffdingTreeClassifier(),
drift_detector=drift.binary.DDM()
)
metric = metrics.Accuracy()
evaluate.progressive_val_score(dataset, model, metric)
Accuracy: 86.46%
Methods¶
learn_one
Update the model with a set of features x
and a label y
.
Parameters
- x
- y
- kwargs
predict_one
Predict the label of a set of features x
.
Parameters
- x — 'dict'
- kwargs
Returns
base.typing.ClfTarget | None: The predicted label.
predict_proba_one
Predict the probability of each label for a dictionary of features x
.
Parameters
- x
- kwargs
Returns
A dictionary that associates a probability which each label.