Proceedings of the Third International Conference on Artificial Intelligence and Smart Energy (ICAIS 2023)
IEEE Xplore Part Number: CFP23OAB-ART; ISBN: 978-1-6654-6216-7
Electricity Price Prediction using Machine Learning
K. Likitha Chowdary Ch. Nanda Krishna K. Srikanshka M anaswini
Department of Information Technology Department of Information Technology Department of Information Technology
Velagapudi Ramakrishna Siddhartha Velagapudi Ramakrishna Siddhartha Velagapudi Ramakrishna. Siddhartha
Engineering College Engineering College Engineering College
Vijayawada, India Vijayawada, India Vijayawada, India
2023 Third International Conference on Artificial Intelligence and Smart Energy (ICAIS) | 978-1-6654-6216-7/23/$31.00 ©2023 IEEE | DOI: 10.1109/ICAIS56108.2023.10073777
kadiyalalikithachowdhury@[Link] nkcherukuri@[Link] manaswinikopparthy@[Link]
B. Jithendra
Department of Information Technology
Velagapudi Ramakrishna Siddhartha
Engineering College
Vijayawada, India
jithendrabojedla9999@[Link]
Abstract—In the era of Digital Transformation, every using our application. The price will be predicted using a
application runs on power which is nothing but electricity. S o, mach ine learning algorith m based on the input data
a proper mechanism is required to analyze the capacity of provided. To empower the application to foresee, it is to be
electricity used in our day-to-day life for domestic as well as
trained in light of the past informat ion about the price o f
industrial purposes. Prediction of price of electricity not only
provides you information about how much you need to pay but
electricity. After training the application forecasts can be
also provide information about how much capacity you are made.
using how much is required and related information. As a The main objectives of our work include studying
proper analysis and prediction of electricity is required, this the different parameters which affect the price of electricity,
research work has developed a model to predict electricity by extracting the important features, developing a model fo r
using machine learning algorithms. Electricity price prediction price pred iction, evaluating the model, and co mparing the
depends on different factors like national wind, wind model with other models.
production and natural factors, etc., due to which it is a
challenging task. Our application deals with regression analysis II. LITERATURE REVIEW
to forecast the value of the dependent variable. The proposed
dataset consists of 18 fields like date and time, month, year, To understand and analyse, this study has examined several
holidays. This study has used four types of regressors namely existing research works and concluded that several
Random Forest Regression, Logistic Regression, Support drawbacks must be taken care of for achieving better
Vector Regressor, and Artificial Neural Network Regressor to performance and accuracy.
predict the price. This study has considered the Mean Absolute
Error (MAE) as an evaluation metric and compared all the In the paper [1], K. Arya and K. R. M. Vijaya Chandrakala
models. The best result is obtained by the ANN Regressor research includes study of the MISO electricity market, the
algorithm. United States wholesale market for electricity, wh ich is used
for the prediction and forecasting of electricity prices
Keywords— Electricity, Price Prediction, Machine learning, consumed. Three methods are being proposed namely Auto
Regressors, Mean Absolute Error. Regressive Integrated Moving Average (ARIMA), decision -
tree-based ensemble Machine Learn ing algorith m namely
I. INT RODUCT ION Extreme Grad ient Boosting (XGboost) and Recurrent
Electricity is one of the most essential requirements that Neural Network (RNN) for predicting the electricity price.
everyone should have for the smooth happening of his/her The proposed model [2] provides more accurate predictions
life in this 21st century. Our day-to-day life is dependent on of future electricity prices than existing fo recast methods.
electricity for its functioning. Fro m mo rning’s alarm in More uniquely, this study presented a novel genetic
phone to night bed-light everything is working on electricity programming system (LSGP). Corresponding authors tested
only. Electricity is also one of the highest economical the system against several existing state-of-the-art
concerns of the country, as its requirement keeps on techniques considered in previous studies to address the
increasing. Over the past years, one of the most concerns for same optimization problem fro m the largest EU energy
people have been less power productivity. What are the most markets.
effective methods for increasing price of electricity? What In this paper [3], new machine learning models are proposed
factors have the greatest impact on electricity price? and achieved cutting edge results. New features are being
Machine learning allows co mputers to learn without having added to the datasets for the imp rovement of perfo rmances
to be exp licit ly programmed. Price of electricity refers to the of the provided M L models. For testing which features have
number o f units consumed in a part icular t ime period. It is the most impact on the predict ions, XAI approaches are
measured in Watts or Kilowatts. applied.
Electricity price prediction depends on mu ltip le This study [4] includes hourly electricity price forecasting
features like weather conditions, government supply price, with a hybrid approach of statistical and regression models.
manage ment practices, and their interactions. So, machine Authors proposed to use a transparent NARMAX model and
learning provides a platform to imp lement electricity price analyze Irish Integrated Single Electricity Market (ISEM )
prediction by using various algorithms. So based on usage data fro m May 2019 until April 2020 to determine which
and atmospheric conditions predicting price o f the external factors have a significant impact on the electricity
electricity is our goal. The electricity price can be predicted
978-1-6654-6216-7/23/$31.00 ©2023 IEEE 611
Authorized licensed use limited to: National Institute of Technology - Puducherry. Downloaded on March 03,2025 at 05:59:45 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Third International Conference on Artificial Intelligence and Smart Energy (ICAIS 2023)
IEEE Xplore Part Number: CFP23OAB-ART; ISBN: 978-1-6654-6216-7
pricing. The results indicate that historical electricity price, System_Load_EP2 Actual national system load.
demand, and system generation are the key factors. SMPEP2 It includes labels or values that must be
This paper [5] proposed an integrated long-term recurrent forecasted as well as the actual cost of
convolutional network (ILRCN) model to predict electricity
the electricity used.
prices considering the majority of contributing attributes to
the market price as input. The p rovided ILRCN model B. Design Methodology
combines the functionalit ies of both convolutional neural
network and long short-term memory (LSTM) algorithm.
In this paper [6], a novel modelling framework fo r
forecasting electricity prices is proposed. For better results,
authors proposed four different deep learning models fo r
predicting electricity prices and showed the fact that how
they lead to improvements in predictive accuracy. Their
research concludes that mach ine learning models yield
better accuracy than statistical models.
III. PROPOSED WORK
A. Dataset:
The dataset considered has eighteen set of attributes:
DateTime, Ho liday, Ho lidayFlag, Day OfWeek, Fig. 1. Architecture of the regressor model
WeekOfYear and so on. The price of the electricity is
estimated based on the historical data of the price of the Fig. 1 shows the design of the proposed work. The
electricity consumed by the machines , which is provided by electricity dataset consists of the historical data for a
the organization. The dataset is taken fro m a published mach inery’s total electricity price. In the preprocessing
research paper. The electricity price predict ion dataset has stage, null values are removed, Label encoding and feature
data for eighteen features (38,014 samples) with 18 co lu mns scaling is done. Next the data is partitioned into training
and 38,015 rows. data (80%) and testing data (20%). Regression models such
The dataset will include the following features : as Random Forest, Log istic Regression, Support Vector
Regressor, and ANN Regressor are given to training data.
T able. 1. ELECT RICIT Y DAT ASET
The testing data is used to evaluate the model. Metrics like
Fe ature Name Information as MSE, MA E, RMSE, and Accuracy are calculated to
assess the model performance.
DateT ime Shows the date and t ime of the record.
Holiday If the day is a national holiday, it C. Data Preprocessing:
includes the name of the holiday. In the pre-processing stage, various techniques are
Holiday_Flag If a bank holiday, it includes value 1, applied. Before imp lementing the model, we firstly
else it contains 0. converted all the string value data type features to float
values using python Pandas library built-in functions. Out of
Day_Of_Week displays values between 0 and 6, with
a total of 18 features, 8 features are o f string values. These
0 denoting a Monday and 6 denoting a features have been converted to numeric values. After that
Sunday. we have removed all the null values present over the dataset
Week_Of_Year It represents the week of that particular by using python Pandas dropna() function. Feature scaling is
year. also done to standardize the values to a fixed range. Finally
iloc[] method of Pandas library is used to extract
Day It contains the day of the date.
independent and dependent variable.
Month Month of the given date. D. Description of Algorithm:
Year It contains the year of a particular date. Our proposed work uses four different regressor models
PeriodOfDay Shows half-hour period of the namely Random Forest, Logistic Regression, Support
Vector Regressor, ANN Regressor. These models will
particular day.
predict the required continuous outcomes which is the actual
Forcast_Wind_Production Represents the rate of forecasted wind cost of electricity used.
production. The follo wing are the algorithms used to build models for
SystemLoadEA It contains the rate of forecasted the electricity price prediction:
1) Random Forest
national load.
SMPEA T he value of predicted price. Random Forest algorith m can be used to perform the
ORK_T emp Measurement of temperature. regressor model with good predict ions which can efficiently
handle large datasets with high accuracy.
ORK_Wspeed T he windspeed which is measured.
The Random Forest working can be explained with the
CO2_Intensity It displays the actual CO2 output per below steps:
unit of electricity generated. 1. In Rando m Forest, n records at random are selected
Actual_WProduction Production of wind energy. from a data collection of k records.
2. New decision trees are built for every sample.
978-1-6654-6216-7/23/$31.00 ©2023 IEEE 612
Authorized licensed use limited to: National Institute of Technology - Puducherry. Downloaded on March 03,2025 at 05:59:45 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Third International Conference on Artificial Intelligence and Smart Energy (ICAIS 2023)
IEEE Xplore Part Number: CFP23OAB-ART; ISBN: 978-1-6654-6216-7
3. An output will be provided by each decision tree. Where
4. For regression, the final result is based on the
averaging. 3. Our object is to maximize the margin or
The limitation of Random Forest is that as it creates several
trees to integrate their outputs, it uses a lot of resources and equivalently to minimize
computational power. 4. After adding the loss function, the landing problem is
2) Logistic Regression
to find a weight vector W that minimizes the cost
Logistic regression algorithm is used to predict the
probability of a b inary outcome. Here, we converted all the function
numerical values in the dependent variable to binary values
(5)
and implemented the model. This gives the res ult in terms of
binary (yes/no) and we take it as the electricity price is high 5. And Gradient descend algorithm can min imize the
or low.
cost function by iteratively updating
The Logistic Regression working can be explained with the
below steps: (6)
1. Extracting dependent and independent Variables
where is learning rate
2. Its equation is of the form –
The SVM will perform poorly when there are mo re features
(1) per data point than the number of training data samples .
4) ANN Regressor
where y is the dependent variable
ANN regressor is a flexible model that can easily adapt to
x1 , x2 , x3, …, xn are independent variables the shape of the data. If the results aren’t accurate enough,
and b0 , b1, …, bn are constants you can easily add further hidden neuron layers in order to
improve its prediction capabilit ies and make it mo re
3. We will fit our regression model to the training set complex.
4. Test the performance of the model using the test data The ANN working can be explained with the below steps:
1. Train the model with three layers namely Input Layer,
5. Confusion matrix is built to check the accuracy
Hidden Layers, Output Layer
2. Initialize weights to small random nu mbers,
(2) associated with biases
where ‘I’ is the indicator function 3. for i:=1 to epochs
‘Te’ is the total number of rows in the dataset 3.1 Calculate the net input to be forwarded to the next unit
(x) is the predicted class 3.2 Apply an activation function to it
c (x) is the actual class 3.3 Calculate the output of that next unit
If there are less observations than features, it is not 3.4 Update the weights and bias by back-propagating the
advisable to apply logistic regression because this could lead
error
to overfitting.
3) Support Vector Regressor ; // compute the error (7)
The SVR tries to fit the best line within a threshold value, where Oj is the actual output of unit j and Tj is the known
unlike other regression models that try to minimize the erro r
between the real and predicted value. target value of the given training tuple
The Support Vector Regressor working can be exp lained ; // weight increment (8)
with the below steps:
1. The equation of the Hyperplane form is: ; // weight update (9)
(3) ; // bias increment (10)
where W is a weight vector, X is the input vector ; // bias update (11)
and b is a bias. where wij is the change in weight wij and where is the
2. The margin is the distance of the closest points from change in bias j
The variable l is the learn ing rate, a constant typically
the Hyperplane and is calculated as: having a value between 0.0 and 1.0.
4. Repeat the process until the model notices no change
in error.
(4)
978-1-6654-6216-7/23/$31.00 ©2023 IEEE 613
Authorized licensed use limited to: National Institute of Technology - Puducherry. Downloaded on March 03,2025 at 05:59:45 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Third International Conference on Artificial Intelligence and Smart Energy (ICAIS 2023)
IEEE Xplore Part Number: CFP23OAB-ART; ISBN: 978-1-6654-6216-7
ANNs require a considerable amount of t rain ing time. The train ing and testing error for the A NN Regressor model
ANNs are fairly slow in the world of co mputer problem is shown in Fig2 The error graph in Fig. 2 is with 300
solving. epochs. At epoch-0 the validation error is 16.452 and the
Loss Functions training erro r is 34.25 and at epoch-300 the validation erro r
is nearly 9.016 and the training error is 4.352. The erro r
1) Mean Squared Error (MSE)
decreases as the number of epochs increases.
(12)
where n is the number of data points
are the observed values
are the predicted values
MSE is a frequently used model evaluation metric in
regression models. It is the mean of the squared difference
of predicted and actual observations. It just cares about the
average amount of error, regardless of its direction.
2) Mean Absolute Error (MAE)
(13)
Fig. 2. MAE and MSE with respect to epochs in ANN Regressor
where n is the number of data points
The ROC curve fro m the logistic reg ression model is
are the observed values
depicted in Fig. 3. ROC curves (Receiver Operating
are the predicted values Characteristic) are useful tools for assessing and fine-
tuning classification models. The curve is built using
The MAE is the average of the absolute deviations of python sklearn library by importing roc_curve fro m that
predictions and actual observations. This, like MSE, it. The x label should be taken with ‘False Positive Rate’
measures the magnitude of errors without considering the and y label is ‘True Negative Rate’. The test is more
direction of the errors. accurate when the curve in the plot is closer to the top
left corner.
IV. RESULTS AND OBSERVATIONS
The model was created and tested on the Google Colab
environment. It's a free notebook environment that enables
Google Drive connections. Colab co mes with a number o f
pre-installed mach ine learn ing libraries, and we can use the
import keyword and the library name to add them to our
notebook. This project makes use of several libraries,
including Pandas, Nu mpy, sklearn, Matplotlib, Keras,
Seaborn, etc. Table 2 contains a tabular representation of the
MAE and M SE for several algorith ms. h is section briefly
discusses about the results obtained fro m the
implementation of proposed frame work and the
observations identified.
Fig. 3. ROC curve for Logistic Regression
T able. 2. MAE AND MSE FOR ALL FOUR MODELS
A. Comparison of Results:
Algorithm Mean Absolute Mean Squared
Name Error Error We have considered the MAE and MSE as evaluation
metrics for our pro ject and co mpared all the models with
Random Forest 9.393 597.48 respect to them. In the four regressors, the best result
Regression was obtained by the ANN Regressor algorithm with an
MAE of 8.7302. Fig 4 shows a chart which represents
Logistic 25.08 0.178 the MAE and MSE of all the algorithms.
Regression We can see that the logistic regression has least MSE
when compared to other algorith ms. In terms of MAE,
Support Vector 12.935 828.12 we observe that ANN has the least. Finally, we can say
Regressor that ANN has obtained the best results because if the
number of epochs is further increased in ANN model,
ANN Regressor 8.7302 59.8905 then the error can be further reduced both in terms MSE
and MAE.
978-1-6654-6216-7/23/$31.00 ©2023 IEEE 614
Authorized licensed use limited to: National Institute of Technology - Puducherry. Downloaded on March 03,2025 at 05:59:45 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Third International Conference on Artificial Intelligence and Smart Energy (ICAIS 2023)
IEEE Xplore Part Number: CFP23OAB-ART; ISBN: 978-1-6654-6216-7
Energy, 221, 386-405.
[Link]
[7] A. Yousefi, O. A. Sianaki and D. Sharafi, "Long-T erm
Electricity Price Forecast Using Machine Learning T echniques,"
2019 IEEE Innovative Smart Grid Technologies - Asia (ISGT
Asia), 2019, pp. 2909-2913, doi: 10.1109/ISGT -
Asia.2019.8881604.
[8] Marszałek, A.; Burczynski T . Forecasting day-ahead spot
electricity prices using deep neural networks with attention
mechanism. J. Smart. Environ. Green. Comput. 2021, 1, 21-31.
[Link]
[9] Kim, Hang & Shin, Hyunjung. (2013). Electricity Price
Prediction Based on Semi-Supervised Learning and Neural
Network Algorithms. Journal of Korean Institute of Industrial
Fig. 4. Comparison of Result Engineers. 39. 10.7232/JKIIE.2013.39.1.030.
[10] Guenoukpati, Agbassou & Salami, Adekunlé & Koffi
V. CONCLUSION AND FUTURE WORK Mawugno, Kodjo & Napo, Kossi. (2021). Short-T erm
Electricity price pred iction is done using machine Electricity Generation Forecasting Using Machine Learning
Algorithms: A Case Study of the Benin Electricity Community
learning techniques based on weather, time, date and other
(C.E.B). TH Wildau Engineering and Natural Sciences
parameters. Machine learn ing is a decision-making tool that Proceedings. 1. 10.52825/thwildauensp.v1i.25
helps in predict ing electricity price, as well as for deciding [11] Fata, Elaheh & Kadota, Igor & Schneider, Ian. (2018).
when more amount of electricity and when less to satisfy Comparison of Classical and Nonlinear Models for Short-T erm
needs. In this paper we have used four types of regressors Electricity Price Prediction.
like Random Forest, Logistic Regression, SVR and ANN [12] H. Deng et al., "Electricity Price Prediction Based on LSTM and
and drawn a conclusion that ANN is the most optimistic LightGBM," 2021 IEEE 4th International Conference on
one. We can benefit from the imp lementation of this project Electronics and Communication Engineering (ICECE), 2021,
pp. 286-290, doi: 10.1109/ICECE54449.2021.9674719.
since it will help them identify the expenditure on
[13] D. A. Mittal, S. Liu and G. Xu, "Electricity Price Forecasting
electricity, allowing them to properly use the resources. This using Convolution and LSTM Models," 2020 7th International
will not only help people in deciding how much power to Conference on Behavioural and Social Computing (BESC),
use in the next season, but it will also aid in the 2020, pp. 1-4, doi: 10.1109/BESC51023.2020.9348313.
technological and industrial div ide. Presently the model is [14] A. Shiri, M. Afshar, A. Rahimi-Kian and B. Maham,
constructed for a particu lar data in s pecific for a machinery "Electricity price forecasting using Support Vector Machines by
company. This can be further extended and used for more considering oil and natural gas price impacts," 2015 IEEE
bigger datasets like country expenditure on electricity and International Conference on Smart Energy Grid Engineering
(SEGE), 2015, pp. 1-5, doi: 10.1109/SEGE.2015.7324591.
further.
[15] C. Yan-Gao and M. Guangwen, "Electricity Price Forecasting
Based on Support Vector Machine Trained by Genetic
REFERENCES Algorithm," 2009 Third International Symposium on Intelligent
Information Technology Application, 2009, pp. 292-295, doi:
[1] K. Arya and K. R. M. Vijaya Chandrakala, "Machine Learning 10.1109/IITA.2009.96.
Based Prediction and Forecasting of Electricity Price During
COVID-19," 2021 IEEE International Power and Renewable
Energy Conference (IPRECON), 2021, pp. 1-6, doi:
10.1109/IPRECON52453.2021.9640701.
[2] Castelli, Mauro & Groznik, Aleš & Popovič, Aleš. (2020).
Forecasting Electricity Prices: A Machine Learning Approach.
Algorithms. 13. 119. 10.3390/a13050119.
[3] Léonard T schora, Erwan Pierre, Marc Plantevit, Céline
Robardet, "Electricity price forecasting on the day-ahead market
using machine learning", Applied Energy, Volume 313, 2022,
118752, ISSN 0306-2619,
[Link]
[4] Catherine McHugh, Sonya Coleman, Dermot Kerr, “Hourly
electricity price forecasting with NARMAX”, Machine
Learning with Applications, Volume 9, 2022, 100383, ISSN
2666-8270, [Link]
[5] Sridharan, V.; T uo, M.; Li, X. Wholesale Electricity Price
Forecasting Using Integrated Long-Term Recurrent
Convolutional Network Model. Energies 2022, 15, 7606.
[Link] en15207606
[6] Lago Garcia, J., De Ridder, F., & De Schutter, B. (2018).
Forecasting spot electricity prices: Deep learning approaches
and empirical comparison of traditional algorithms. Applied
978-1-6654-6216-7/23/$31.00 ©2023 IEEE 615
Authorized licensed use limited to: National Institute of Technology - Puducherry. Downloaded on March 03,2025 at 05:59:45 UTC from IEEE Xplore. Restrictions apply.