采用 facebook 的prophet 预测科大讯飞的股票开盘价
在运行代码前需要安装fbprophet和tushare,然后拷贝代码可直接运行,个人认为facebook的这个开源不怎么样,回测的效果不行.不如lstm甚至简单的多元回归.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 18 09:26:40 2018
@author: 罗干
"""
import pandas as pd
import numpy as np
from fbprophet import Prophet
import matplotlib.pyplot as plt
import tushare as ts
de=ts.get_hist_data('002230',start='2016-01-25',end='2017-11-01')
df=pd.DataFrame()
df['y']=de['open']
df['ds']=list(de.index)
# 定义模型
m = Prophet()
# 训练模型
m.fit(df)
# 构建预测集
future = m.make_future_dataframe(periods=60)
print (future.tail())
# 进行预测
forecast = m.predict(future)
m.plot(forecast)
plt.show()