Facebook 由于缺少fit_类,无法编译StanModel
我正在尝试使用Facebook提供的这一创新预测工具,名为Facebook Prophet()。但是当我尝试使用“fit” 特色。目前,我在Anaconda环境中使用Python,包括Pystan的2.14版本、Pandas的0.20.2版本和Python的3.5版本。我不明白我为什么会遇到这个问题,有人能帮我吗 我的代码:Facebook 由于缺少fit_类,无法编译StanModel,facebook,stan,Facebook,Stan,我正在尝试使用Facebook提供的这一创新预测工具,名为Facebook Prophet()。但是当我尝试使用“fit” 特色。目前,我在Anaconda环境中使用Python,包括Pystan的2.14版本、Pandas的0.20.2版本和Python的3.5版本。我不明白我为什么会遇到这个问题,有人能帮我吗 我的代码: import pandas as pd import numpy as np from fbprophet import Prophet import matplotlib
import pandas as pd
import numpy as np
from fbprophet import Prophet
import matplotlib.pyplot as plt
import pystan
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
plt.rcParams['axes.labelsize'] = 14
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['ytick.labelsize'] = 12
jet=plt.get_cmap('coolwarm')
datapath = "/Users/tuanle/DynamicPricing/Data/"
HAN_BIKE = pd.read_csv(datapath+ "HAN-BIKE_1year_CompletedOrders.csv")
HAN_BIKE['to_char'] = pd.DatetimeIndex(HAN_BIKE['to_char'])
HAN_BIKE = HAN_BIKE.rename(columns={'to_char': 'ds', 'hourr': 'hour','completed_orders': 'y'})
HAN_BIKE['ds'] = HAN_BIKE[['ds','hour']].apply(lambda x : '{}{}'.format(x[0],x[1]), axis=1)
pd.pivot_table(HAN_BIKE, index = ["hour"], values = ["percent_completed", "y"])
HAN_BIKE = HAN_BIKE.drop("hour", axis=1)
HAN_BIKE.hist(bins=50, figsize=(10,15))
HAN_BIKE = HAN_BIKE.drop("percent_completed", axis=1)
# HAN_BIKE.set_index('ds').plot()
HAN_BIKE.loc[(HAN_BIKE['y'] > 500), 'y'] = np.nan
HAN_BIKE.loc[(HAN_BIKE['y'] <= 10), 'y'] = np.nan
HAN_BIKE['y'] = np.log(HAN_BIKE['y'])
# HAN_BIKE.set_index('ds').plot()
HAN_BIKE.hist(bins = 50, figsize = (10,15))
m = Prophet(yearly_seasonality=True)
m.fit(HAN_BIKE)
看起来您使用的是pystan的旧版本。在您的virtualenv中,请尝试:
pip3安装——升级pystan这里没有人能帮我解决上述问题吗?我在上面添加了代码供您参考。
WARNING:pystan:numpy.core.multiarray failed to import
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
WARNING:pystan:numpy.core.multiarray failed to import
WARNING:pystan:Something went wrong while unpickling the StanModel. Consider recompiling.
Disabling yearly seasonality. Run prophet with yearly_seasonality=True to override this.
AttributeError Traceback (most recent call last)
in ()
11 HAN_BIKE["ds"] = HAN_BIKE["ds"].values.astype('datetime64[D]')
12 m = Prophet()
---> 13 m.fit(HAN_BIKE)
/Applications/anaconda/lib/python3.5/site-packages/fbprophet/forecaster.py in fit(self, df, **kwargs)
533
534 else:
--> 535 params = model.optimizing(dat, init=stan_init, iter=1e4, **kwargs)
536 for par in params:
537 self.params[par] = params[par].reshape((1, -1))
/Applications/anaconda/lib/python3.5/site-packages/pystan/model.py in optimizing(self, data, seed, init, sample_file, algorithm, verbose, as_vector, **kwargs)
466 data = {}
467
--> 468 fit = self.fit_class(data)
469
470 m_pars = fit._get_param_names()
AttributeError: 'StanModel' object has no attribute 'fit_class''