You are on page 1of 13

Short And Long Term Traffic Prediction

121AD0015
Summary of the Traffic Dataset:

- The dataset contains four main features: Hour, Lane 1 Flow (Veh/Hour),
Lane 1 Occ (%), and Lane 1 Speed (mph).

Visualizations of Traffic Features Over Time:

-
Data Normalization using MinMaxScaler:

Visual representation showcasing the process of normalizing the data.


The build_lstm_model function defines a sequential model,
incorporating LSTM layers that allow the network to retain
memory over sequences, enabling the model to capture
temporal dependencies within the traffic data.

Role of input_shape and activation function:


The code specifies the input shape and activation function
within the LSTM layer. The input_shape=(seq_length,
num_features) denotes the input data shape passed to the
LSTM layer, indicating the sequence length and the number
of features. Moreover, the activation function used, in this
case, relu (Rectified Linear Unit), helps introduce non-
linearity within the LSTM layer, allowing the model to learn
complex patterns and relationships within the traffic data.
model.compile(optimizer='adam',
loss='mean_squared_error')

This line specifies the Adam optimizer to be


used in the compilation of the LSTM model,
employing the mean squared error as the loss
function
The line model.fit(X_train_short, y_train_short,
epochs=epoch, batch_size=64) implies a batch size
of 64. Therefore, the model is being trained using
mini-batch gradient descent, where the dataset is
divided into smaller batches, and the model
parameters are updated after processing each
batch. This strategy combines the advantages of
stochastic gradient descent (updates after every
sample) and full batch gradient descent (updates
after the entire dataset) to achieve a balance
between efficiency and robustness in training.
Default hyper-parameter values such as epochs
and batch size are used to train initial models
for short and long-term predictions. The
resulting Root Mean Square Error (RMSE) values
are calculated and visualized to understand
the accuracy of these predictions, helping
assess the model's performance. Finally, a
comparative graph displaying the RMSE against
the varying epoch values is created, providing
a comprehensive view of the impact of
different epochs on prediction accuracy.
Analyzing how varying epochs affect both long-term and
short-term predictions sheds light on the intricate
connection between training duration and the accuracy
of predictions. This examination offers valuable insights
into determining the most effective training durations
for each specific forecasting horizon within LSTM models.
a subplot visualization of epochs versus
short-term predictions
a subplot visualization of epochs versus
Long -term predictions
Comparison between Short-Term Predictions and
Actual Short-Term Values:
Comparison between Long-Term Predictions and Actual
Long-Term Values:
Thank You

You might also like