我让这个模型用于多变量多步序列预测。
def build_model(train,n_input):
train_x, train_y = to_supervised(train, n_input)
verbose, epochs, batch_size = 1, 60,20
n_timesteps, n_features, n_outputs = train_x.shape[1], train_x.shape[2], train_y.shape[1]
train_y = train_y.reshape((train_y.shape[0], train_y.shape[1], 1))
model = Sequential()
model.add(LSTM(200, activation='relu', input_shape=(n_timesteps, n_features)))
model.add(RepeatVector(n_outputs))
model.add(LSTM(200, activation='relu', return_sequences=True))
model.add(TimeDistributed(Dense(100, activation='relu')))
model.add(TimeDistributed(Dense(1)))
model.compile(loss='mse', optimizer='adam', metrics=['accuracy'])
model.fit(train_x, train_y, epochs=epochs, batch_size=batch_size, verbose=verbose)
return model
我得到了这个结果:
Epoch 59/60
5516/5516 [==============================] - 21s 4ms/step - loss: 1.8988 - acc: 0.5636: 1s - loss: 1.
Epoch 60/60
5516/5516 [==============================] - 22s 4ms/step - loss: 1.8556 - acc: 0.5685
R2得分:
r2_score(test[:,-1], pred)
0.8688880951315198
从以上结果来看,我有一些疑问:
1)如何测量模型的准确性?是采取训练准确性(此处为loss: 1.8556 - acc: 0.5685
还是采取r2 score
来衡量准确性。
2)如何提高我的准确性?我再次尝试使用LSTM -CNN获得类似结果。
请帮助我提高准确性。