Holidays issue forecast in FB Prophet recent versions
- 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

This is the code

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

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
Assessment
This issue has not been assessed yet.