From 2a39c42b5879c02f400850430f1355be57e9ffbb Mon Sep 17 00:00:00 2001 From: Saulo Martiello Mastelini Date: Thu, 26 Oct 2023 18:34:44 -0300 Subject: [PATCH] streamline test --- river/drift/no_drift.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/river/drift/no_drift.py b/river/drift/no_drift.py index 1762e665fc..c5173aca04 100644 --- a/river/drift/no_drift.py +++ b/river/drift/no_drift.py @@ -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 @@ -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: @@ -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