ARTICLE AD BOX
I am using the Jupyter notebook to run the Facebook Prophet model using Python code.
Below are the steps I followed:
import pandas as pd import numpy as np import matplotlib.pyplot as plt from statsmodels.graphics.tsaplots import month_plot, quarter_plot, plot_acf, plot_pacf from statsmodels.tsa.seasonal import seasonal_decompose from sklearn.model_selection import ParameterGrid from sklearn.metrics import root_mean_squared_error, mean_absolute_error, mean_absolute_percentage_error df = pd.read_csv("Daily Bike Sharing training.csv") df.head()| 0 | 1 | 1/1/2011 | 1 | 0 | 1 | 0 | 6 | 0 | 2 | 0.344167 | 0.363625 | 0.805833 | 0.160446 | 331 | 654 | 985 |
| 1 | 2 | 1/2/2011 | 1 | 0 | 1 | 0 | 0 | 0 | 2 | 0.363478 | 0.353739 | 0.696087 | 0.248539 | 131 | 670 | 801 |
| 2 | 3 | 1/3/2011 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0.196364 | 0.189405 | 0.437273 | 0.248309 | 120 | 1229 | 1349 |
| 3 | 4 | 1/4/2011 | 1 | 0 | 1 | 0 | 2 | 1 | 1 | 0.200000 | 0.212122 | 0.590435 | 0.160296 | 108 | 1454 | 1562 |
| 4 | 5 | 1/5/2011 | 1 | 0 | 1 | 0 | 3 | 1 | 1 | 0.226957 | 0.229270 | 0.436957 | 0.186900 | 82 | 1518 | 1600 |
Change the time series variable name
df = df.rename(columns = {'cnt':'y', 'dteday': 'ds'}) df.head()Change 'ds' into format YYYY-MM-DD
df['ds'] = pd.to_datetime(df['ds'], format = "%m/%d/%Y") df.head()Prepare the weather situation variable
weather_sit = pd.get_dummies(df['weathersit'], drop_first = True) weather_sit df = pd.concat([df, weather_sit], axis = 1)
Rename variables 2 and 3
df = df.rename(columns = {2: 'weathersit_2', 3: 'weathersit_3'}) df.head()Drop variable that are not needed
df.drop(columns = ['instant', 'season', 'yr', 'mnth', 'weekday', 'casual', 'registered'], inplace = True) df.head()Check the holidays in our data frame
df[df.holiday == 1].dsHolidays
gen_holidays = pd.DataFrame({'holiday': 'gen_holi', 'ds': df[df.holiday == 1].ds, 'lower_window': -2, 'upper_window': 2}) xmas = pd.DataFrame({'holiday': 'christmas', 'ds': pd.to_datetime(['2011-12-24', '2012-12-24']), 'lower_window': -3, 'upper_window': 3}) nye = pd.DataFrame({'holiday': 'new_years', 'ds': pd.to_datetime(['2011-12-31', '2012-12-31']), 'lower_window': -3, 'upper_window': 3}) easter = pd.DataFrame({'holiday': 'easter', 'ds': pd.to_datetime(['2011-04-24', '2012-04-08']), 'lower_window': -3, 'upper_window': 3})Combine all the holidays
holidays = pd.concat([gen_holidays, xmas, nye, easter])Import model
from prophet import ProphetRemove any NAs
df = df.dropna() # Building the Prophet model m = Prophet( yearly_seasonality = True, weekly_seasonality = True, holidays = holidays, seasonality_mode = 'multiplicative', seasonality_prior_scale = 10, holidays_prior_scale = 10, changepoint_prior_scale = 0.05) m.add_regressor('workingday') m.add_regressor('temp') m.add_regressor('atemp') m.add_regressor('hum') m.add_regressor('windspeed') m.add_regressor('weathersit_2') m.add_regressor('weathersit_3')Then:
When I type:
m.fit(df)It is giving me the following error message:
The procedure entry point ZNi5seekgESt4fposI9MbstateE could not be located in the dynamic link library C:\Users\UserName\anaconda3\Lib\site-packages\prophet\stan_model\prophet_model.binI used the anaconda prompt to uninstall and re-install prophet using these lines of code:
conda remove prophet conda remove pystan conda install -c conda-forge prophetAfter re-installing prophet, restarting jupyter notebook, I run the same lines of codes I outlined above, and it is giving me the same error message.
I am not sure what to do next and I would greatly appreciate any suggestions to resolve this issue.

