non-daily_data.md (prophet-1.1) | : | non-daily_data.md (prophet-1.1.1) | ||
---|---|---|---|---|

skipping to change at line 24 | skipping to change at line 24 | |||

id: holidays-with-aggregated-data | id: holidays-with-aggregated-data | |||

--- | --- | |||

<a id="sub-daily-data"> </a> | <a id="sub-daily-data"> </a> | |||

## Sub-daily data | ## Sub-daily data | |||

Prophet can make forecasts for time series with sub-daily observations by passin g in a dataframe with timestamps in the `ds` column. The format of the timestamp s should be YYYY-MM-DD HH:MM:SS - see the example csv [here](https://github.com/ facebook/prophet/blob/main/examples/example_yosemite_temps.csv). When sub-daily data are used, daily seasonality will automatically be fit. Here we fit Prophet to data with 5-minute resolution (daily temperatures at Yosemite): | Prophet can make forecasts for time series with sub-daily observations by passin g in a dataframe with timestamps in the `ds` column. The format of the timestamp s should be YYYY-MM-DD HH:MM:SS - see the example csv [here](https://github.com/ facebook/prophet/blob/main/examples/example_yosemite_temps.csv). When sub-daily data are used, daily seasonality will automatically be fit. Here we fit Prophet to data with 5-minute resolution (daily temperatures at Yosemite): | |||

```R | ```R | |||

# R | # R | |||

df <- read.csv('../examples/example_yosemite_temps.csv') | df <- read.csv('https://raw.githubusercontent.com/facebook/prophet/main/examples /example_yosemite_temps.csv') | |||

m <- prophet(df, changepoint.prior.scale=0.01) | m <- prophet(df, changepoint.prior.scale=0.01) | |||

future <- make_future_dataframe(m, periods = 300, freq = 60 * 60) | future <- make_future_dataframe(m, periods = 300, freq = 60 * 60) | |||

fcst <- predict(m, future) | fcst <- predict(m, future) | |||

plot(m, fcst) | plot(m, fcst) | |||

``` | ``` | |||

```python | ```python | |||

# Python | # Python | |||

df = pd.read_csv('../examples/example_yosemite_temps.csv') | df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/exampl es/example_yosemite_temps.csv') | |||

m = Prophet(changepoint_prior_scale=0.01).fit(df) | m = Prophet(changepoint_prior_scale=0.01).fit(df) | |||

future = m.make_future_dataframe(periods=300, freq='H') | future = m.make_future_dataframe(periods=300, freq='H') | |||

fcst = m.predict(future) | fcst = m.predict(future) | |||

fig = m.plot(fcst) | fig = m.plot(fcst) | |||

``` | ``` | |||

![png](/prophet/static/non-daily_data_files/non-daily_data_4_0.png) | ![png](/prophet/static/non-daily_data_files/non-daily_data_4_0.png) | |||

The daily seasonality will show up in the components plot: | The daily seasonality will show up in the components plot: | |||

skipping to change at line 112 | skipping to change at line 112 | |||

The same principle applies to other datasets with regular gaps in the data. For example, if the history contains only weekdays, then predictions should only be made for weekdays since the weekly seasonality will not be well estimated for th e weekends. | The same principle applies to other datasets with regular gaps in the data. For example, if the history contains only weekdays, then predictions should only be made for weekdays since the weekly seasonality will not be well estimated for th e weekends. | |||

<a id="monthly-data"> </a> | <a id="monthly-data"> </a> | |||

## Monthly data | ## Monthly data | |||

You can use Prophet to fit monthly data. However, the underlying model is contin uous-time, which means that you can get strange results if you fit the model to monthly data and then ask for daily forecasts. Here we forecast US retail sales volume for the next 10 years: | You can use Prophet to fit monthly data. However, the underlying model is contin uous-time, which means that you can get strange results if you fit the model to monthly data and then ask for daily forecasts. Here we forecast US retail sales volume for the next 10 years: | |||

```R | ```R | |||

# R | # R | |||

df <- read.csv('../examples/example_retail_sales.csv') | df <- read.csv('https://raw.githubusercontent.com/facebook/prophet/main/examples /example_retail_sales.csv') | |||

m <- prophet(df, seasonality.mode = 'multiplicative') | m <- prophet(df, seasonality.mode = 'multiplicative') | |||

future <- make_future_dataframe(m, periods = 3652) | future <- make_future_dataframe(m, periods = 3652) | |||

fcst <- predict(m, future) | fcst <- predict(m, future) | |||

plot(m, fcst) | plot(m, fcst) | |||

``` | ``` | |||

```python | ```python | |||

# Python | # Python | |||

df = pd.read_csv('../examples/example_retail_sales.csv') | df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/exampl es/example_retail_sales.csv') | |||

m = Prophet(seasonality_mode='multiplicative').fit(df) | m = Prophet(seasonality_mode='multiplicative').fit(df) | |||

future = m.make_future_dataframe(periods=3652) | future = m.make_future_dataframe(periods=3652) | |||

fcst = m.predict(future) | fcst = m.predict(future) | |||

fig = m.plot(fcst) | fig = m.plot(fcst) | |||

``` | ``` | |||

![png](/prophet/static/non-daily_data_files/non-daily_data_16_0.png) | ![png](/prophet/static/non-daily_data_files/non-daily_data_16_0.png) | |||

This is the same issue from above where the dataset has regular gaps. When we fi t the yearly seasonality, it only has data for the first of each month and the s easonality components for the remaining days are unidentifiable and overfit. Thi s can be clearly seen by doing MCMC to see uncertainty in the seasonality: | This is the same issue from above where the dataset has regular gaps. When we fi t the yearly seasonality, it only has data for the first of each month and the s easonality components for the remaining days are unidentifiable and overfit. Thi s can be clearly seen by doing MCMC to see uncertainty in the seasonality: | |||

```R | ```R | |||

# R | # R | |||

m <- prophet(df, seasonality.mode = 'multiplicative', mcmc.samples = 300) | m <- prophet(df, seasonality.mode = 'multiplicative', mcmc.samples = 300) | |||

fcst <- predict(m, future) | fcst <- predict(m, future) | |||

prophet_plot_components(m, fcst) | prophet_plot_components(m, fcst) | |||

``` | ``` | |||

```python | ```python | |||

# Python | # Python | |||

m = Prophet(seasonality_mode='multiplicative', mcmc_samples=300).fit(df) | m = Prophet(seasonality_mode='multiplicative', mcmc_samples=300).fit(df, show_pr ogress=False) | |||

fcst = m.predict(future) | fcst = m.predict(future) | |||

fig = m.plot_components(fcst) | fig = m.plot_components(fcst) | |||

``` | ``` | |||

WARNING:pystan:481 of 600 iterations saturated the maximum tree depth of 10 (80.2 %) | WARNING:pystan:481 of 600 iterations saturated the maximum tree depth of 10 (80.2 %) | |||

WARNING:pystan:Run again with max_treedepth larger than 10 to avoid saturati on | WARNING:pystan:Run again with max_treedepth larger than 10 to avoid saturati on | |||

![png](/prophet/static/non-daily_data_files/non-daily_data_19_1.png) | ![png](/prophet/static/non-daily_data_files/non-daily_data_19_1.png) | |||

The seasonality has low uncertainty at the start of each month where there are d ata points, but has very high posterior variance in between. When fitting Prophe t to monthly data, only make monthly forecasts, which can be done by passing the frequency into `make_future_dataframe`: | The seasonality has low uncertainty at the start of each month where there are d ata points, but has very high posterior variance in between. When fitting Prophe t to monthly data, only make monthly forecasts, which can be done by passing the frequency into `make_future_dataframe`: | |||

End of changes. 5 change blocks. | ||||

5 lines changed or deleted | | 5 lines changed or added |