The sample dataset contains Location point of the user.
df.head()
user tslot Location_point
0 0 2015-12-04 13:00:00 4356
1 0 2015-12-04 13:15:00 4356
2 0 2015-12-04 13:30:00 3659
3 0 2015-12-04 13:45:00 4356
4 0 2015-12-04 14:00:00 8563
df.shape
(288,3)
As the location points are categorical values they are one hot encoded.
encoded = to_categorical(df['Location_point'])
The encoded values are as below
[[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
...
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]
[0. 0. 0. ... 0. 0. 0.]]
Shape of the encoded values is (288,8564).
I tried to shape the training data
X_trai = []
y_trai = []
for i in range(96, 288):
X_trai.append(encoded[i-96:i])
y_trai.append(encoded[i])
X_trai, y_trai = np.array(X_trai), np.array(y_trai)
X_trai = np.reshape(X_trai, (X_trai.shape[0], X_trai.shape[1], 1))
And the model is
regressor = Sequential()
regressor.add(LSTM(units = 50, return_sequences = True, input_shape = (X_trai.shape[1], 1)))
regressor.add(Dropout(0.2))
regressor.add(LSTM(units = 50, return_sequences = True))
regressor.add(Dropout(0.2))
regressor.add(LSTM(units = 50, return_sequences = True))
regressor.add(Dropout(0.2))
regressor.add(LSTM(units = 50))
regressor.add(Dropout(0.2))
regressor.add(Dense(units = 1))
regressor.compile(optimizer = 'adam', loss = 'mean_squared_error')
regressor.fit(X_trai, y_trai, epochs = 100, batch_size = 32)
This is not the correct model. I am new to deep learning. I tried to see some example but not able to understand for one hot encoding. I would be grateful if someone can explain the input shape, output shape, and the correct model.
The input is the sequence of the location points and the output is to predict
the next location point for that user.