facebook - 由于缺少 fit_class,StanModel 无法编译

标签 facebook stan

我正在尝试使用 Facebook 提供的名为 Facebook Prophet (https://research.fb.com/prophet-forecasting-at-scale/) 的创新预测工具。但是当我尝试使用 "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.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)

错误信息:

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''

最佳答案

2021 年:

安装 prophet 而不是 fbprophet

pip install pystan==2.19.1.1
pip install prophet

关于facebook - 由于缺少 fit_class,StanModel 无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45055726/

相关文章:

Facebook (#32) 达到页面请求限制

facebook - api 从 facebook 上的个人资料 URL 获取 uid

ios - 架构 i386 的 undefined symbol : "_OBJC_CLASS_$_Facebook", 从 : objc-class-ref in AppDelegate. o 引用

javascript - Facebook 视频播放器 API xfbml.ready 无法在移动设备上运行。如何获取视频实例?

php - Facebook 聊天如何运作?

r - stan 中的有序概率

stan - 如何从 stanfit 对象中提取估计值

r - 如何使用 rstanarm 以 APA 样式报告贝叶斯线性(混合)模型?

c++ - 在 C++ 应用程序中嵌入 Stan

c++ - 当 Rtools 安装在 Windows 7 的非默认目录中时,在 R 中编译 Stan 模型