Prophet意为先知、预言家。Prophet is a forecasting procedure implemented in R and Python. It is fast and provides completely automated forecasts that can be tuned by hand by data scientists and analysis’s.
Prophet 是一个用R和Python实现的预测程序。它提供了快速和完全自动的预测功能并且可以被数据科学家以及数据分析师手动调节。
Prophet is a procedure for forecasting time series data. It is based on an additive model where non-linear trends are fit with yearly and weekly seasonality, plus holidays. It works best with daily periodicity data with at least one year of historical data. Prophet is robust to missing data, shifts in the trend, and large outliers. —— [ Prophet GitHub ]
Prophet is open source software released by Facebook’s Core Data Science team. It is available for download on CRAN and PyPI.
Accurate and fast.
Prophet is used in many applications across Facebook for producing reliable forecasts for planning and goal setting. We’ve found it to perform better than any other approach in the majority of cases. We fit models in Stan so that you get forecasts in just a few seconds.
Fully automatic.
Get a reasonable forecast on messy data with no manual effort. Prophet is robust to outliers, missing data, and dramatic changes in your time series.
Tunable forecasts.
The Prophet procedure includes many possibilities for users to tweak and adjust forecasts. You can use human-interpretable parameters to improve your forecast by adding your domain knowledge.
Available in R or Python.
We’ve implemented the Prophet procedure in R and Python, but they share the same underlying Stan code for fitting. Use whatever language you’re comfortable with to get forecasts.
以上的简介内容以及写的很清楚了,prophet主要是做时间序列分析用的,他是基于加法模型的。并且对于周期性的周,年,月,节假日等也能做很好的分析。详情知乎上也有人写,写的很详细
这是官网的quickstart的内容,csv文件也可以下到,这个入门以后后面调试加入其它参数就很简单了
import pandas as pd
import numpy as np
from fbprophet import Prophet
import matplotlib.pyplot as plt
df = pd.read_csv('prophet2.csv')
df['y'] = np.log(df['y'])
df.head()
m = Prophet()
m.fit(df);
future = m.make_future_dataframe(periods=365)
future.tail()
forecast = m.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']])
m.plot(forecast)
x1 = forecast['ds']
y1 = forecast['yhat']
plt.plot(x1,y1)
plt.show()
Pycharm运行的输出:
INFO:fbprophet.forecaster:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pystan/misc.py:399: FutureWarning: Conversion of the second argument of issubdtype fromfloat
tonp.floating
is deprecated. In future, it will be treated asnp.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 7977.53 0.00518255 463.655 0.8852 0.8852 135
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
199 7989.23 0.00307225 291.618 1 1 254
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
299 7996.64 0.000424198 188.254 0.3548 0.3548 372
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
370 7998.78 4.32656e-05 122.355 1.874e-07 0.001 515 LS failed, Hessian reset
399 8000 0.000790631 130.422 1 1 550
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
451 8000.56 4.3555e-05 129.171 4.574e-07 0.001 673 LS failed, Hessian reset
499 8001.08 3.66338e-05 97.2042 0.6272 0.6272 731
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
599 8003.02 0.000298985 75.36 1 1 854
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
699 8003.86 0.00037674 169.914 1 1 987
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
775 8004.5 2.62833e-05 70.2915 1.778e-07 0.001 1122 LS failed, Hessian reset
799 8004.51 6.11757e-07 63.7049 0.2884 1 1152
Iter log prob ||dx|| ||grad|| alpha alpha0 # evals Notes
801 8004.51 3.83161e-07 59.8318 1 1 1156
Optimization terminated normally:
Convergence detected: relative gradient magnitude is below tolerance
ds yhat yhat_lower yhat_upper
0 2007-12-10 8.847226 8.218079 9.432748
1 2007-12-11 8.595701 7.960684 9.190026
2 2007-12-12 8.391457 7.718059 9.029698
3 2007-12-13 8.369342 7.772091 8.995339
4 2007-12-14 8.357241 7.769005 9.006983
5 2007-12-15 8.102504 7.496323 8.687237
6 2007-12-16 8.452322 7.800830 9.105626
7 2007-12-17 8.748916 8.121334 9.355626
8 2007-12-18 8.511673 7.897954 9.126313
9 2007-12-19 8.323772 7.687726 8.974427
10 2007-12-20 8.319671 7.707258 8.910700
11 2007-12-21 8.326839 7.692221 8.968682
12 2007-12-22 8.092194 7.512884 8.689739
13 2007-12-23 8.462500 7.847964 9.075577
14 2007-12-24 8.779560 8.118666 9.366083
15 2007-12-25 8.562370 7.990415 9.176699
16 2007-12-26 8.393750 7.798918 9.037238
17 2007-12-27 8.407842 7.785592 8.990071
18 2007-12-28 8.431848 7.769104 9.039373
19 2007-12-29 8.212476 7.588937 8.817966
20 2007-12-30 8.596336 7.928292 9.182823
21 2007-12-31 8.925136 8.305920 9.557538
22 2008-01-01 8.717833 8.035471 9.333388
23 2008-01-02 8.557268 7.961706 9.172460
24 2008-01-03 8.577647 7.948425 9.203908
25 2008-01-04 8.606283 8.005904 9.210183
26 2008-01-05 8.390029 7.770943 8.969497
27 2008-01-06 8.775664 8.167639 9.381086
28 2008-01-07 9.105085 8.484348 9.745439
29 2008-01-08 8.897439 8.214288 9.501276
… … … … …
3240 2016-12-21 7.525974 6.844214 8.259231
3241 2016-12-22 7.530564 6.832433 8.258724
3242 2016-12-23 7.546106 6.821247 8.256757
3243 2016-12-24 7.319388 6.632002 8.001619
3244 2016-12-25 7.697061 7.048241 8.413254
3245 2016-12-26 8.020842 7.309507 8.777245
3246 2016-12-27 7.809661 7.080042 8.521368
3247 2016-12-28 7.646300 6.914492 8.392658
3248 2016-12-29 7.664885 6.951041 8.374673
3249 2016-12-30 7.692626 6.989347 8.386938
3250 2016-12-31 7.476258 6.775442 8.194275
3251 2017-01-01 7.862440 7.192813 8.531319
3252 2017-01-02 8.192941 7.463441 8.914721
3253 2017-01-03 7.986792 7.275324 8.721447
3254 2017-01-04 7.826911 7.126223 8.508503
3255 2017-01-05 7.847591 7.109858 8.553419
3256 2017-01-06 7.876223 7.093871 8.578842
3257 2017-01-07 7.659735 6.969517 8.401893
3258 2017-01-08 8.044974 7.345377 8.752373
3259 2017-01-09 8.373887 7.724712 9.109538
3260 2017-01-10 8.165659 7.447216 8.889333
3261 2017-01-11 8.003336 7.242737 8.748439
3262 2017-01-12 8.021295 7.259737 8.728679
3263 2017-01-13 8.046975 7.303786 8.796182
3264 2017-01-14 7.827303 7.111407 8.552474
3265 2017-01-15 8.209074 7.464623 8.899218
3266 2017-01-16 8.534139 7.843166 9.281436
3267 2017-01-17 8.321541 7.618165 9.067944
3268 2017-01-18 8.154138 7.426741 8.822908
3269 2017-01-19 8.166091 7.445606 8.881803
[3270 rows x 4 columns]
objc[1683]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/FinderKit (0x126ef4b68) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x117fb1cd8). One of the two will be used. Which one is undefined.
还是很好用的,还可以吧fred设置成min就可以预测分钟的数据了,速度也还可以,不算太慢,预测效果还行,神器。