This project aims to predict the power load for two stations using historical load data. The model employs deep learning techniques, including Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM), and Gated Recurrent Units (GRU), to forecast future load values. The prediction is done for the year 1403 in the Persian calendar.
- Installation
- Usage
- Data Preparation
- Model Architecture
- Training and Evaluation
- Generating Predictions
- Results
- Clone the repository:
git clone https://github.com/adibshirazi/ElectricalLoadPredictor.git
- Navigate to the project directory:
cd ElectricalLoadPredictor
- Install the required packages:
pip install -r requirements.txt
- Ensure the Excel files
sorted_station1_data.xlsx
andsorted_station2_data.xlsx
are in the project directory. - Run the script:
python model_training.py
- Loading Data: The historical load data is loaded from two Excel files,
sorted_station1_data.xlsx
andsorted_station2_data.xlsx
, into Pandas DataFrames. - Combining Data: The data from the two stations are combined into a single DataFrame based on the
date
column. - Adding Lag Features: Lag features are added to the DataFrame to include previous load values, which help the model learn temporal patterns.
- Scaling Data: The combined data is scaled using MinMaxScaler to normalize the values for better model performance.
Three different deep learning models are used for prediction:
- Convolutional Neural Network (CNN): This model uses Conv1D layers to capture spatial patterns in the time series data, followed by MaxPooling, Flatten, Dense, and Dropout layers.
- Long Short-Term Memory (LSTM): The LSTM model uses LSTM layers to capture long-term dependencies in the time series data, followed by Dense and Dropout layers.
- Gated Recurrent Unit (GRU): The GRU model is similar to the LSTM model but uses GRU layers, which are computationally more efficient.
- K-Fold Cross-Validation: The data is split into 5 folds, and each model is trained and evaluated on each fold to ensure robustness.
- Early Stopping and Model Checkpointing: Early stopping is used to prevent overfitting, and the best model is saved using model checkpointing.
- Evaluation Metrics: Mean Squared Error (MSE) and R² Score are used to evaluate model performance.
- Future Date Generation: Future dates for the year 1403 are generated in the Persian calendar.
- Inverse Transformation: The predicted values are inverse transformed to their original scale.
- Saving Predictions: The predictions are saved to an Excel file named
predictions_1403.xlsx
.
The model's performance is evaluated based on the average MSE and R² score across all folds. The final predictions for the year 1403 are saved in an Excel file, providing the forecasted power load for each hour and station.
This project is licensed under the AGPL-3.0 License. See the LICENSE file for details.