Skip to content

Commit

Permalink
streamline test
Browse files Browse the repository at this point in the history
  • Loading branch information
Saulo Martiello Mastelini committed Oct 26, 2023
1 parent 56b708f commit 2a39c42
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions river/drift/no_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NoDrift(base.DriftDetector):
It always signals that no concept drift was detected.
Examples
--------
>>> from river import drift
>>> from river import evaluate
>>> from river import forest
Expand All @@ -20,27 +20,17 @@ class NoDrift(base.DriftDetector):
... seed=8,
... position=500,
... width=40,
... )
... ).take(700)
We can turn off the warning detection capabilities of Adaptive Random Forest (ARF) or
other similar models. Thus, the base models will reset immediately after identifying a drift,
bypassing the background model building phase:
>>> model = forest.ARFClassifier(
>>> adaptive_model = forest.ARFClassifier(
... leaf_prediction="mc",
... warning_detector=drift.NoDrift(),
... seed=8
... )
>>> metric = metrics.Accuracy()
>>> evaluate.progressive_val_score(dataset.take(700), model, metric)
Accuracy: 76.25%
>>> model.n_drifts_detected()
2
>>> model.n_warnings_detected()
0
We can also turn off the concept drift handling capabilities completely:
Expand All @@ -50,10 +40,22 @@ class NoDrift(base.DriftDetector):
... drift_detector=drift.NoDrift(),
... seed=8
... )
>>> metric = metrics.Accuracy()
>>> evaluate.progressive_val_score(dataset.take(700), stationary_model, metric)
Accuracy: 76.25%
Let's put that to test:
>>> for x, y in dataset:
... adaptive_model = adaptive_model.learn_one(x, y)
... stationary_model = stationary_model.learn_one(x, y)
The adaptive model:
>>> adaptive_model.n_drifts_detected()
2
>>> adaptive_model.n_warnings_detected()
0
The stationary one:
>>> stationary_model.n_drifts_detected()
0
Expand Down

0 comments on commit 2a39c42

Please sign in to comment.