1
votes

I'm currently learning on LSTMs and time series prediction with LSTMs. And I try to predict speeds for a road segment.

from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler()
training_set = sc.fit_transform(training_set)

X_train = training_set[0:1257] //speed at (t)
y_train = training_set[1:1258] //speed at (t+1)

X_train = np.reshape(X_train, (1257, 1, 1))

from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LSTM

regressor = Sequential()
regressor.add(LSTM(units=4, activation='sigmoid', input_shape= (None, 1)))
regressor.add(Dense(units=1))
regressor.compile(optimizer='rmsprop', loss='mean_squared_error')
regressor.fit(X_train, y_train, batch_size=10, epochs=100)

Above contains a part of my code and I use that to predict speed at time t+1 for a road segment using keras. Training set contains 1258 records of speeds at 5 min intervals. By the above code, using LSTM I could predict speed for t+1. i.e. speed for next 5 min. How can I predict speed for a larger timestep (say next 15 min).

1

1 Answers

0
votes

Just change your training input like this:

X_train = training_set[0:1255] //speed at (t)
y_train = training_set[3:1258] //speed at (t+3)