我获得了从2014年8月2日到现在的日期(08/02/2019)的时间序列数据。在此代码中,RNN可以预测结果并将其与测试集进行比较。我想预测比测试集更多的东西,例如预测到15/02/2019如何使用Keras预测比数据集更多的东西?
df = pdr.get_data_yahoo('ibm',
start=datetime.datetime(2014, 02, 08),
end=pd.datetime.now().date())
train = df.loc[:datetime.datetime(2019, 1,14), ['Close']]
test = df.loc[datetime.datetime(2019, 1,15):, ['Close']]
sc = MinMaxScaler()
train_sc = sc.fit_transform(train)
test_sc = sc.transform(test)
X_train = train_sc[:-1]
y_train = train_sc[1:]
X_test = test_sc[:-1]
y_test = test_sc[1:]
K.clear_session()
model = Sequential()
model.add(Dense(12, input_dim=1, activation='relu'))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
model.summary()
model.fit(X_train, y_train, epochs=200, batch_size=2)
y_pred = model.predict(X_test)