补全代码def predict_price(model, data, window_size): # 预测股票价格 obs = np.array([ data.loc[len(data) - window_size:len(data), 'Open'].values / 200, data.loc[len(data) - window_size:len(data), 'High'].values / 200, data.loc[len(data) - window_size:len
时间: 2023-11-29 13:06:17 浏览: 149
好的,补全代码如下:
```
def predict_price(model, data, window_size):
# 预测股票价格
obs = np.array([
data.loc[len(data) - window_size:len(data), 'Open'].values / 200,
data.loc[len(data) - window_size:len(data), 'High'].values / 200,
data.loc[len(data) - window_size:len(data), 'Low'].values / 200,
data.loc[len(data) - window_size:len(data), 'Close'].values / 200,
data.loc[len(data) - window_size:len(data), 'Volume'].values / 100000000
])
obs = np.reshape(obs, (obs.shape[1], obs.shape[0], 1))
prediction = model.predict(obs)
prediction = prediction.reshape(-1)
return prediction * 200
```
这段代码将股票数据中最后 `window_size` 天的开盘价、最高价、最低价、收盘价和成交量作为输入数据 `obs`,然后将其传入已训练好的 `model` 中进行预测。最后将预测值乘以200,得到预测的股票价格。
阅读全文