Skip to content

'Recent' metrics: Should Metrics be Link-able? #498

Answered by raphaelsty
pjz asked this question in Q&A
Discussion options

You must be logged in to vote

To calculate the accuracy with an exponential average I would do it like this:

from river import stats

metric = stats.EWMean(alpha = 0.5)

y_pred = [1, 1, 1, 1, 1]
y_true = [0, 0, 1, 1, 1]

for pred, true in zip(y_pred, y_true):
    metric.update(pred == true)
    
print(metric.get())

1.0

So I'm reduced to doing a Rolling Accuracy over a kind of arbitrarily sized chosen 'recent' sample size. You will choose an equally arbitrary alpha coefficient for the exponential average. Personally, I find the RollingAccuracy more easily interpretable.

from river import metrics

metric = metrics.Rolling(metrics.Accuracy(), window_size=3)

y_pred = [1, 1, 1, 1, 1]
y_true = [0, 0, 1, 1, 1]

for pred, true 

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by MaxHalford
Comment options

You must be logged in to vote
1 reply
@pjz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants