It seems that you want to understand that how could you use your dataset and apply LSTMs over it to get some meaningful out of your data.
Now here you can reframe your data set to create more features from your present data set for eg.
Features That could be derived out of Data
- Take Out day of the month (which day is it 1-31)
- Week of the month (which week of month it is 1-4)
- Day of the week (Monday - Saturday)
- what is the time ( you can have any of the value out of 188)
Features that could be added from opensource data
- What is the wheather of the day
- Is there any holiday nearby(days remaining for next holiday/function etc.)
Now let's Assume for each row you have K features in your data and you have a target that you have to predict which is what is the availability of parking.
P(#parking_space|X)
Now just just keep your timesteps as a variable while creating your model and reshape your data from X.shape-->(Examples, Features) to the format X.shape-->(examples,Timesteps,Features). You can use below code and define your own look_back
Here your architecture will be many to many with Tx=Ty
def create_dataset_many_to_many(dataset,look_back=70):
data_timestamp=[]
for i in range(len(dataset)-look_back):
data_timestamp.append(dataset[i:i+look_back])
if i%1000==0:
print(i)
return np.array(data_timestamp)
Now you can build model
import tensorflow as tf
import matplotlib.pyplot as plt
# Importing pandas
import pandas as pd
# Importing keras model
from tensorflow.keras.models import Model
# Importing layers like input and dense
from tensorflow.keras.layers import Dense, Input,LSTM,Dropout
#importing train test split
from sklearn.model_selection import train_test_split
class Lstm_model(tf.keras.Model):
def __init__(self, **kwargs):
super(Lstm_model, self).__init__()
self.Lstm1 = tf.keras.layers.LSTM(32,return_sequences=True)
self.Lstm2 = tf.keras.layers.LSTM(32,return_sequences=True)
self.Regressor = tf.keras.layers.Dense(1, )
def call(self, inputs):
input_A=inputs
x = self.Lstm1(input_A)
x = self.Lstm2(x)
pred = self.Regressor(x)
return pred
lstms_ = Lstm_model()
lstms_.compile(optimizer='adam', loss=tf.keras.losses.MeanSquaredError())
lstms_.fit(X,Y, epochs=50)
This is just a glimpse of how you can make your model.