Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Scaled CRPS is possibly incorrect #140

Open
elephaint opened this issue Dec 3, 2024 · 1 comment
Open

[BUG] Scaled CRPS is possibly incorrect #140

elephaint opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@elephaint
Copy link
Contributor

Our implementation of scaled crps scales each timeseries according to the absolute value of the observed values of each timeseries, but the original GluonTS implementation (and the one we also follow in hierarchicalforecast) scales the CRPS based on the norm calculated across all timeseries.

Is this intentional?

To make things concrete, the following shows how the code for a Pandas DF should be adapted to reflect the GluonTS / HF behavior.

loss = loss.set_index(id_col)
sizes = sizes.set_index(id_col)
assert isinstance(df, pd.DataFrame)
- norm = df[target_col].abs().groupby(df[id_col], observed=True).sum()
+ norm = df[target_col].abs().sum()
- res = 2 * loss.mul(sizes['counts'], axis=0).div(norm + eps, axis=0)
+ res = 2 * loss.mul(sizes['counts'].sum(), axis=0).div(norm + eps, axis=0)        
res.index.name = id_col
res = res.reset_index()
@elephaint elephaint added the bug Something isn't working label Dec 3, 2024
@jmoralez
Copy link
Member

jmoralez commented Dec 3, 2024

I think the whole point of having a scale is for the metric to be comparable across series, similar to MASE. If you use a global scale you're just dividing everything by a constant and the metric is dominated by series with large values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants