<jupyter_start><jupyter_text>Prequential Error<jupyter_code>import numpy as np
from sklearn import datasets as skdatasets
from river.stream import iter_sklearn_dataset
from river.naive_bayes import GaussianNB
from river.metrics import Accuracy
iris = skdatasets.load_iris()<jupyter_output><empty_output><jupyter_text>The `progressive_val_score` methodThe [progressive_val_score](https://riverml.xyz/latest/api/evaluate/progressive-val-score/) method implements the prequential evaluation. It requires three components: - a data stream- a model- a metric<jupyter_code>from river.evaluate import <FILL-IN>

# Setup stream and estimators
stream = iter_sklearn_dataset(iris, shuffle=True, seed=42)
model = GaussianNB()
metric = Accuracy()
print_every=10

# Setup evaluator
<FILL-IN><jupyter_output><empty_output><jupyter_text>The [progressive_val_score](https://riverml.xyz/latest/api/evaluate/progressive-val-score/) method saves all the predictions in memory and uses all of them to compute the metrics  Sliding Window Prequential Error---The [Rolling](https://riverml.xyz/latest/api/metrics/Rolling/) method is a wrapper that allows you to apply a metric over a window of observations. Under the hood, a buffer with the window_size most recent pairs of (y_true, y_pred) is memorised. When the buffer is full, the oldest pair is removed and the revert method of the metric is called with said pair.<jupyter_code>from river.metrics import <FILL-IN>

window_size=50

metric = <FILL-IN>
model = GaussianNB()

for x, y in iter_sklearn_dataset(iris, shuffle=True, seed=42):
    y_p = <FILL-IN>   # Predict class
    if y_p is not None:
        print(<FILL-IN>)
    <FILL-IN>       # Train the model<jupyter_output><empty_output><jupyter_text>Fading Factor Prequential Error---It gives more importance to the new predictions and less importance to the oldest ones.The estimation is updated in this way:- correct_pred = $\alpha$ * correct_pred + value- total_seen = $\alpha$ * total_seen + 1.0with $0 < \alpha \leq 1$. The larger $\alpha$ is, the greater the old predictions importance is.<jupyter_code>correct_pred = 0.0
total_seen = 0.0
alpha = 0.95

print_every = 10
i = 1
instance = 1

model = GaussianNB()

for x, y in iter_sklearn_dataset(iris, shuffle=True, seed=42):
    y_p = <FILL-IN>    # Predict class
    if y_p is not None:
        to_add = 0.0
        if y == y_p:
            to_add = <FILL-IN>                                
        correct_pred = <FILL-IN> 
        total_seen = <FILL-IN> 
   
    if instance == print_every * i:
        if total_seen > 0:
            print('[' + str(instance) + '] Accuracy: ' + str(np.round((correct_pred / total_seen * 100),2)) + '%')
        else:
            print('[' + str(instance) + '] Accuracy: 0.00%')
        i += 1
        
    <FILL-IN>         # Train the model
    instance += 1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10181311018131102, 'fraction_numerical': 0.01290097629009763, 'mean_word_length': 3.665040650406504, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '397518', 'license': 'Apache-2.0', 'n_tokens_mistral': 957, 'n_tokens_neox': 906, 'n_words': 280, 'path': 'lab/1.0_Prequential_Error.ipynb', 'repo_name': 'quantiaconsulting/streamin-machine-learning', 'size': '2868'}