gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:50:49 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com