TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

ARIMA vs. LSTM: Forecasting Electricity Consumption

Which model performs better?

Michael Grogan
TDS Archive
Published in
8 min readDec 12, 2020

Source: Photo by Comfreak from Pixabay

Note: The full article can be found here, along with a link to the relevant GitHub repository for this example.

In this example, the ARIMA and LSTM models are used to predict electricity consumption patterns for the Dublin City Council Civic Offices, Ireland.

The data in question is sourced from data.gov.ie.

Specifically, the data is provided in terms of kilowatt consumption every 15 minutes.

The analysis takes three stages:

  1. Relevant data manipulation procedures are invoked in order to aggregate the total kilowatt consumption per day, i.e. form a daily time series.
  2. Forecast kilowatt consumption across the test set using an ARIMA model.
  3. Generate another forecast across the test set using an LSTM model and examine if the predictions improve.

Data Manipulation

Here is the original set of data loaded into Python.

df = pd.read_csv('dccelectricitycivicsblocks34p20130221-1840.csv', engine='python', skipfooter=3)
df
Source: Jupyter Notebook Output

We can see that for each date, the relevant kilowatt consumption is provided across 15-minute intervals.

However, in this instance we wish to forecast the total daily consumption and there is expected to be too much volatility if the time series is formed on a 15-minute basis — so as to make any forecasts quite superficial.

In this regard, the data is sorted on a daily basis:

df2=df.rename(columns=df.iloc[0])
df3=df2.drop(df.index[0])
df3
df3.drop(df3.index[0])
df4=df3.drop('Date', axis=1)
df5=df4.drop('Values', axis=1)
df5
df6=df5.dropna()
df7=df6.values
df7
dataset=np.sum(df7, axis=1, dtype=float)
dataset

The relevant columns are renamed accordingly, and the kilowatt consumption per day is aggregated.

A numpy array containing the aggregated daily data is formed:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Michael Grogan
Michael Grogan

Written by Michael Grogan

Statistical Data Scientist | Python and R trainer | Financial Writer | michael-grogan.com

Responses (2)

Write a response