一、简介:
fbprophet是facebook开发的关于时间序列预测的开源工具包,具体的介绍请参考
https://facebook.github.io/prophet/
重头戏来了!!!开发程序最耗费时间的总是环境配置
二、环境配置:
fbprophet一直遵循简单及美的编程准则,前期开发确实节省了很多时间。但是fbprophet最最恶心的就是环境配置,当我在pycharm写上import fbprophet准备点击install时就已经犯了玩 fbprophet的大忌。
废话不多少了,直接上错误可能的类型:
1:安装VC++这是必须的,这里我们只需在CSDN上下载VC++2014之后的版本就可以了。这里推荐使用, https://download.csdn.net/download/a120224169/7556675
2:安装pystan 网上有很多安装的方案这里推荐直接pip。
3:LINK : fatal error LNK1158: cannot run 'rc.exe' error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158
解决方案如下 :
Add this to your PATH environment variables:
C:\Program Files (x86)\Windows Kits\8.0\bin\x86
Copy these files:
rc.exercdll.dll
From
C:\Program Files (x86)\Windows Kits\8.0\bin\x86
To
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin
3:直接在github上下载 fbprophet 然后 python setup.py install 就可以了。
三、运行测试
import pandas as pd from fbprophet import Prophet import quandl import pytrends #from stocker import Stocket df = pd.read_csv('examples/example_wp_log_peyton_manning.csv') print(df.head()) m = Prophet() print(m.fit(df))
0 2007-12-10 9.590761
1 2007-12-11 8.519590
2 2007-12-12 8.183677
3 2007-12-13 8.072467
4 2007-12-14 7.893572
INFO:fbprophet.forecaster:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
C:\python36\lib\site-packages\pystan\misc.py:399: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
elif np.issubdtype(np.asarray(v).dtype, float):
Initial log joint probability = -19.4685
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
99 7974.23 0.000415888 246.991 1 1 129
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
162 7991.26 7.17392e-05 165.119 1.7e-07 0.001 246 LS failed, Hessian reset
199 7994.41 0.000222195 99.3075 1 1 287
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
271 7997.43 6.23574e-05 197.621 2.967e-07 0.001 427 LS failed, Hessian reset
299 7998.44 0.00104688 208.909 1 1 463
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
399 8000.12 0.000178706 78.7234 0.3993 0.3993 584
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
499 8002.96 0.000659776 87.4522 1 1 708
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
580 8003.58 5.65739e-05 175.42 3.512e-07 0.001 847 LS failed, Hessian reset
599 8003.8 0.00140602 134.118 1 1 872
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
699 8004.08 0.00797648 132.668 1 1 994
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
721 8004.38 6.06341e-05 154.879 6.644e-07 0.001 1062 LS failed, Hessian reset
799 8004.7 0.00072854 100.447 1 1 1149
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
879 8004.75 6.24151e-07 80.6455 9.227e-09 0.001 1294 LS failed, Hessian reset
889 8004.75 3.96358e-07 74.9798 0.4128 1 1306
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
<fbprophet.forecaster.Prophet object at 0x000001CB5B25A518>