This document provides an overview and explanation of the code designed to train an LSTM (Long Short-Term Memory) model to predict wind speed based on historical data.
This project includes a detailed report available in PDF format and Google Colab Execution.
The primary purpose of this code is to predict wind speed using an LSTM model. The model is trained on historical wind speed data to forecast future values.
- Input CSV File Structure:
- Station ID: Unique identifier for the weather station.
- Location: Geographical location of the station.
- Date: Date of the recorded wind speed.
- Wind Speed: Recorded wind speed (in km/h or mph).
- The code reads the CSV file using Pandas.
- It extracts the wind speed values from the 4th column.
- A plot is generated to visualize wind speed variations over time.
- Three input features (X1, X2, X3) are created by shifting the wind speed data.
- Each prediction is based on the wind speeds of the previous three days.
- Both input features and target values are scaled to a range between 0 and 1 using MinMaxScaler.
- An LSTM model is defined using the Sequential API.
- The model is trained on 80% of the data for 25 epochs.
- The loss for each epoch is displayed during training.
- The model makes predictions on the test set (20% of data).
- Two plots are generated:
- Scatter Plot: Compares actual vs. predicted wind speed values.
- Line Plot: Shows actual and predicted wind speed over time.
- Scatter Plot: Visualizes the accuracy of predictions against actual values.
- Line Plot: Illustrates how well the model captures trends and fluctuations in wind speed.
The final output allows for a visual assessment of the LSTM model's performance in predicting wind speeds based on historical data. A successful model will have predictions closely following actual values in the line plot and points clustering around a diagonal line in the scatter plot.