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 ('base.Classifier')
The classifier and background classifier class.
-
drift_detector ('base.DriftAndWarningDetector | base.BinaryDriftAndWarningDetector | None') – defaults to
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 ('bool') – defaults to
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.40%
Methods¶
learn_one
Update the model with a set of features x
and a label y
.
Parameters
- x
- y
- kwargs
Returns
self
predict_one
Predict the label of a set of features x
.
Parameters
- x (dict)
- kwargs
Returns
typing.Union[bool, str, int, NoneType]: 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.