facebook / facebook/prophet

How to get performance_metrics() on weekly frequency in facebook-prophet?

Open
#2,400 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
20.4k
Forks
4.6k
Avg merge
19h 52m
Merged PRs (30d)
1

Description

[I am working with prophet library for educational purpose on a classic dataset:
the [air passenger dataset available on Kaggle](https://www.kaggle.com/datasets/yasserh/air-passengers-forecast-dataset).

Data are on monthly frequency which is not possible to cross validate as standard frequency on Prophet, [based on that discussion](https://github.com/facebook/prophet/issues/1672).

During the cross validation for Time Series I used the prophet function `cross_validation()` passing the arguments on weekly frequency.

But when I call the function `performance_metrics` it returns the horizon column on **daily frequency**.

How can I get on weekly frequency?

I also tried to read the documentation and the [function description](https://github.com/facebook/prophet/blob/e665430adcd7690a1ea7565803f34043596045fe/python/prophet/diagnostics.py#L318):

> Metrics are calculated over a rolling window of cross validation predictions, after sorting by horizon. Averaging is first done within each value of horizon, and then across horizons as needed to reach the window size. The size of that window (number of simulated forecast points) is determined by the rolling_window argument, which specifies a proportion of simulated forecast points to include in each window. rolling_window=0 will compute it separately for each horizon. The default of rolling_window=0.1 will use 10% of the rows in df in each window. rolling_window=1 will compute the metric across all simulated forecast points. The results are set to the right edge of the window.

Here how I modelled the dataset:
```
model = Prophet()
model.fit(df)
future_dates = model.make_future_dataframe(periods=36, freq='MS')

df_cv = cross_validation(model,
initial='300 W',
period='5 W',
horizon = '52 W')
df_cv.head()
```
prophet

And then when I call the performance_metrics
```
df_p = performance_metrics(df_cv)
df_p.head()
```
This is the output that I get with a daily frequency.
prophet2

I am probably missing something or I made a mistake in the code.
I also discussed about this isue on [this stack overflow question](
https://stackoverflow.com/questions/75450844/how-to-get-performance-metrics-on-weekly-frequency-in-facebook-prophet) with no reply.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.