python - “TypeError: can't pickle _thread.RLock objects”,同时使用 pickle 保存 Facebook Prophet 模型
问题描述
我正在训练一个模型来使用 Facebook Prophet 模型预测能耗值。但是在使用 pickle 保存模型时,我收到了这个错误:
TypeError Traceback (most recent call last)
<ipython-input-54-9ef2990419d8> in <module>
1 with open('forecast_model.pckl', 'wb') as fout:
----> 2 pickle.dump(model, fout)
TypeError: can't pickle _thread.RLock objects
代码 :
from fbprophet import Prophet
import pickle
model = Prophet()
model.fit(df)
with open('forecast_model.pkl', 'wb') as fout: <== Error coming here
pickle.dump(model, fout)
df.head()
ds y
0 2018-12-19 15:00:02 250.0
1 2018-12-19 16:00:03 295.0
2 2018-12-19 18:00:02 288.0
3 2018-12-19 19:00:02 286.0
4 2018-12-19 20:00:02 229.0
[编辑]解决方案链接:https : //github.com/facebook/prophet/issues/1361:
下面给出的代码对我有用
model = Prophet()
model.stan_backend.logger = None
with open('test.pickle', 'wb') as f:
pickle.dump(m, f)
解决方案
我有同样的问题。我重新安装了 fbprophet 0.5 版,比如
pip install -U fbprophet==0.5
如果你不需要最新版本:0.6,你可以试试。
推荐阅读
- javascript - 使用 getByDisplayValueText 在反应测试库中找不到按钮
- python - 抓取存在某些问题的网站
- javascript - Javascript SetTimeout函数在执行后不暂停
- python - 为什么 DBSCAN.fit() 更快,功能更多?
- android - Android 设备和 Unity 连接失败
- php - Atlassian Bamboo 内置的 PHP Docker 镜像存在权限错误
- noclassdeffounderror - 使用 ZoneRulesProvider 时间歇性遇到 NoClassDefFoundError
- python - 除非带引号,否则 Python 字符串输入会出错
- python - 试图将高斯函数拟合到数据中
- jquery - SELECTED 动态选择