liuyuqi-dellpc 9 months ago
parent
commit
e892db7595
3 changed files with 59 additions and 1 deletions
  1. 12 1
      README.md
  2. 44 0
      main.py
  3. 3 0
      requiremets.txt

+ 12 - 1
README.md

@@ -1,3 +1,14 @@
 # prophet
 # prophet
 
 
-Facebook 开源 时间序列预测的工具
+Facebook 开源 时间序列预测的工具
+
+
+## Usage
+
+## Reference
+
+https://github.com/facebook/prophet
+
+
+## License
+

+ 44 - 0
main.py

@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+"""
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2024/07/03
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   
+"""
+
+import pandas as pd
+from prophet import Prophet
+import matplotlib.pyplot as plt
+
+# 创建示例数据
+data = {
+    'ds': pd.date_range(start='2022-01-01', periods=365, freq='D'),
+    'y': [x + (x * 0.1) for x in range(365)]
+}
+df = pd.DataFrame(data)
+
+
+# 创建 Prophet 模型实例
+model = Prophet()
+
+# 训练模型
+model.fit(df)
+
+# 创建未来日期数据框架
+future = model.make_future_dataframe(periods=30)  # 预测未来 30 天
+
+# 进行预测
+forecast = model.predict(future)
+
+# 绘制预测结果
+fig1 = model.plot(forecast)
+plt.show()
+
+# 绘制预测成分(趋势、周效应、年效应等)
+fig2 = model.plot_components(forecast)
+plt.show()
+
+
+if __name__=='__main__':
+    pass

+ 3 - 0
requiremets.txt

@@ -0,0 +1,3 @@
+prophet==1.1.5
+pandas==2.2.2
+numpy==2.0.0