facebook / facebook/prophet

Holidays issue forecast in FB Prophet recent versions

Open
#2,454 1 comment 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

Hi!

I'm trying to predict the revenues of a company. I included a holidays dataframe which are descount dates. First I was using 1.1.2 version of Prophet but when a plot the forecast and see the final forecast the model aren't including the holidays. This error has happened before in previuos version to 0.6 but some users solved that issue updating the version. I don't know how to resolve this because now it's not about the version ¿What can I do?

This is the holiday dataframe
![image](https://github.com/facebook/prophet/assets/36315264/2f246bbb-c7d9-4e25-822d-89ba5d824278)

This is the code
![image](https://github.com/facebook/prophet/assets/36315264/9950164b-cb31-42b4-ba27-0a4b2d6b9c81)

I notice that de future dataframe aren't including the holidays by the values forecasted because when I try to plot the components of the forecast

![image](https://github.com/facebook/prophet/assets/36315264/7100dd23-fd67-4e1a-a699-28c48589ae60)

This is the error I have:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
[~\AppData\Roaming\Python\Python37\site-packages\pandas\core\indexes\base.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/pandas/core/indexes/base.py) in get_loc(self, key, method, tolerance)
3360 try:
-> 3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:
[~\AppData\Roaming\Python\Python37\site-packages\pandas\_libs\index.pyx](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/pandas/_libs/index.pyx) in pandas._libs.index.IndexEngine.get_loc()
[~\AppData\Roaming\Python\Python37\site-packages\pandas\_libs\index.pyx](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/pandas/_libs/index.pyx) in pandas._libs.index.IndexEngine.get_loc()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas\_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'trend'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
[~\AppData\Local\Temp\ipykernel_10968\4287718603.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Local/Temp/ipykernel_10968/4287718603.py) in
----> 1 m.plot_components(forecast);

[~\AppData\Roaming\Python\Python37\site-packages\prophet\forecaster.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/prophet/forecaster.py) in plot_components(self, fcst, uncertainty, plot_cap, weekly_start, yearly_start, figsize)
1867 m=self, fcst=fcst, uncertainty=uncertainty, plot_cap=plot_cap,
1868 weekly_start=weekly_start, yearly_start=yearly_start,
-> 1869 figsize=figsize
1870 )
[~\AppData\Roaming\Python\Python37\site-packages\prophet\plot.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/prophet/plot.py) in plot_components(m, fcst, uncertainty, plot_cap, weekly_start, yearly_start, figsize)
162 plot_forecast_component(
163 m=m, fcst=fcst, name='trend', ax=ax, uncertainty=uncertainty,
--> 164 plot_cap=plot_cap,
165 )
166 elif plot_name in m.seasonalities:
[~\AppData\Roaming\Python\Python37\site-packages\prophet\plot.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/prophet/plot.py) in plot_forecast_component(m, fcst, name, ax, uncertainty, plot_cap, figsize)
225 ax = fig.add_subplot(111)
226 fcst_t = fcst['ds'].dt.to_pydatetime()
--> 227 artists += ax.plot(fcst_t, fcst[name], ls='-', c='#0072B2')
228 if 'cap' in fcst and plot_cap:
229 artists += ax.plot(fcst_t, fcst['cap'], ls='--', c='k')
[~\AppData\Roaming\Python\Python37\site-packages\pandas\core\frame.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/pandas/core/frame.py) in __getitem__(self, key)
3456 if self.columns.nlevels > 1:
3457 return self._getitem_multilevel(key)
-> 3458 indexer = self.columns.get_loc(key)
3459 if is_integer(indexer):
3460 indexer = [indexer]
[~\AppData\Roaming\Python\Python37\site-packages\pandas\core\indexes\base.py](https://file+.vscode-resource.vscode-cdn.net/z%3A/ANALITICA%20DE%20CLIENTES/CIENTIFICOS%20DE%20DATOS/Karen%20Roma%C3%B1a/Financiera/Facturaci%C3%B3n/~/AppData/Roaming/Python/Python37/site-packages/pandas/core/indexes/base.py) in get_loc(self, key, method, tolerance)
3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:
-> 3363 raise KeyError(key) from err
3364
3365 if is_scalar(key) and isna(key) and not self.hasnans:
KeyError: 'trend'

Can someine give me some guide that can help me to solve this,

Thanks!

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.