This notebook presents a comprehensive analysis of predicting the price of electricity in Spain using various machine learning algorithms. The main focus is on exploring different techniques, including Linear Regression, XGBRegressor, LSTM, Bidirectional LSTM, and Convolutional 1D models. PyTorch is employed for the deep learning experiment.
Electricity price prediction is a crucial task in the energy sector, as it enables stakeholders to make informed decisions about energy production, consumption, and trading. Accurate price forecasting helps utilities, grid operators, and consumers optimize resource allocation and manage costs effectively.
The dataset used in this project is available on google drive and can be downloaded using gdown
, and consists of two main parts:
-
Energy Generation Data: This dataset contains historical information about energy generation, likely including details about different sources of energy generation, their capacities, and outputs over time.
-
Weather Data: The weather dataset includes historical weather information such as temperature, wind speed, humidity, and other relevant factors that may impact electricity prices.
Both datasets are crucial for predicting electricity prices as they provide valuable insights into the factors affecting energy production and consumption.
The following dependencies are required to run the notebook:
- Python==3.11
- Jupyter Notebook
- Pandas
- NumPy
- Matplotlib
- Scikit-learn
- torch==2.3.0+cu121
You can install the required libraries using pip:
pip install pandas numpy matplotlib scikit-learn
The notebook covers the following main topics:
-
Data Exploration and Preprocessing: Exploring the dataset, handling missing values, and preprocessing the data for model training.
-
Feature Engineering: Creating additional features from the existing ones to improve model performance.
-
Model Selection and Training: Trying out different machine learning algorithms such as Linear Regression, Random Forest, and Gradient Boosting Regression for predicting electricity prices.
-
Model Evaluation: Evaluating the performance of each model using Root Mean Squared Error (RMSE).
-
Hyperparameter Tuning: Fine-tuning the hyperparameters of the best-performing model to optimize its performance further.
-
Conclusion: Summarizing the findings and suggesting potential areas for improvement or further research.
To use the notebook, follow these steps:
- Clone or download this repository to your local machine.
- Install the required dependencies as mentioned above.
- Open the Jupyter Notebook using the following command:
jupyter notebook "Electricity Price Pred.ipynb"
- Execute the cells in the notebook sequentially to reproduce the analysis and results.
The dataset and code in this repository are provided under the MIT License. Feel free to use and modify them for your own projects. If you find this work helpful, consider giving it a star on GitHub!
credit: electricity price forecasting