這里記錄用keras LSTM搭建模型做基于時(shí)間序列的數(shù)據(jù)預(yù)測(t+1 value based on t, t-1, t-2 etc.).
- 建模
首先,keras LSTM網(wǎng)絡(luò)模型需要輸入數(shù)據(jù)有這樣的形式:
model.add (LSTM(samples, input_shape=(timesteps, data_dim)))
You can find a keras example here.
在input_shape的兩個(gè)基本參數(shù)中,timesteps和data_dim對于同一 組數(shù)據(jù)是可以結(jié)合數(shù)據(jù)預(yù)處理 1.5 Reshape input data調(diào)整的。
- Train data訓(xùn)練
model.fit(X_train, y_train, epochs=epoch, batch_size=batcsize, verbose=1)
- Make prediction
model.predict(X_test)