Peaky Finders: Machine Learning and Dash for the US Electric Grid
Tags: Machine Learning, Xgboost, Dash, Data Science, Plotly

Peaky Finders: Machine Learning and Dash for the US Electric Grid plotly Follow Jun 18 · 8 min read

📌 To learn more, view our recorded webinar on August 4th, 2021 here ➡️ https://go.plotly.com/machine-learning-for-electric-grid

Author: Kyle Baranko

App: https://dash-gallery.plotly.host/dash-peaky-finders

Source Code: https://github.com/kbaranko/peaky-finders

What is an ISO?

Electricity is the underlying force enabling all the gadgets and technologies of modern civilization, yet we only tend to think about it when we can’t get it. Even this week, as Texans welcome summertime after unexpectedly frigid and snowy conditions, the threat of scorching temperatures on the vulnerable grid is making concerned leaders ask consumers to conserve electricity use.

The link between grid reliability and intense weather is fresh in everyone’s mind. With so much of the economy and our livelihoods dependent on 24/7 access to energy, and with climate change magnifying the likelihood of extreme weather events, ensuring the grid is operating reliably is more important than ever.

February 2021 in Fort Worth, Texas. | Ron Jenkins/Getty Images

Who controls the grid? The answer depends on where you live. Some areas in the United States are operated by a vertically integrated utility that controls all grid infrastructure from generating assets, like coal plants or solar farms, to transmission lines that deliver the electricity to major load centers, and finally, to the distribution systems that deliver power to consumers. However, much of the country is also under the purview of independent system operators (ISOs). ISOs run competitive electricity markets with a variety of stakeholders while ensuring the overall system functions efficiently and reliably.

Optimizing efficiency and reliability is extremely complicated, and surprisingly, the two goals often conflict with one another. Running the grid efficiently often translates to lowering costs, while running the grid reliably means ensuring there is enough generation to handle unexpected outages or spikes in demand — a task that often requires overbuilding generation capacity (and raising costs). ISOs also have to coordinate the financial settlement that comes with the buying and selling of electricity across different timescales (day ahead, real time, and even years-ahead), as well as the engineering challenges required to keep this complex machine humming without interruption (ensuring power is flowing safely, regulating frequency, etc.).

To navigate all this complexity, it is incredibly important for ISOs and all grid stakeholders to predict peak electricity demand, or peak “load”, with some degree of reliable accuracy to ensure there is enough generation to meet demand. Peak load is also important for generators, who may need to determine when it will be economically optimal to produce electricity on a given day, and consumers, who may want to avoid high prices or peak demand charges (the amount on your bill determined by usage during peak load events).

Peaky Finders is a Plotly Dash application with helpful peak load visualizations and a day ahead forecasting model for five different ISOs. It does not demonstrate cutting-edge peak load forecasting methods — there are a handful of high tech companies and millions of dollars spent trying to solve this problem — but rather illustrate core concepts and explore how well a model can do with just historical load and temperature data.

Homepage

On the Peaky Finders homepage, you’ll find basic information about the app, buttons to navigate to a dashboard page for each ISO, and a map outlining ISO territories in the US.

The map shows how the grid in the US is actually a patchwork of small regional grids, each with a unique governing structure; wholesale electricity markets and the ISOs that run them come in all shapes and sizes.

Although the entire US is shown in the map, Peaky Finders has a model for only five ISOs:

California Independent System Operator (CAISO)

Midcontinent Independent System Operator (MISO)

Pennsylvania, Jersey, Maryland Power Pool (PJM)

New York Independent System Operator (NYISO)

Independent System Operator New England (ISONE)

Dash provides many easy-to-use methods that make page navigation intuitive without coding in HTML. For each ISO, the link to the page was wrapped around around a button:

dcc.Link( html.Button(‘CAISO’, id=’caiso-button’, className=”mr-1"), href=’/caiso’)

As for the map, you’re seeing a GeoPandas dataframe rendered via Plotly Express, which provides many built-in classes and methods for illustrating geographic data. Plotly.express made it easy to show the territory of each ISO as well as the rest of the country as a choropleth map:

dcc.Graph(figure=px.choropleth())

The Models

Electricity demand is primarily a function of two variables: time and weather. We consume more energy during the daytime and evenings when using lots of electronic devices and during weekdays when offices are open. Electricity consumption also varies with the weather due to heating and cooling. Demand rises in the summer when people are using air conditioning to combat the heat and, for regions with electrified heating, in the winter when combating the cold. This is a complex modeling problem with many more caveats, but Peaky Finders was built to measure how well a machine learning model could perform using only these features.

Historical load data was collected using the Pyiso python library, which provides clean API interfaces to make scraping ISO websites easy. The Darksky API was used for weather data, which provides historical temperature readings for a given latitude and longitude. For this model, I picked one central coordinate in each ISO territory to make API requests.

After acquiring and cleaning hourly data for the years from 2018–2021, the training pipeline engineered the following five features, and then fitted an XGBoost model. XGBoost is a decision-tree-based ensemble machine learning algorithm that also uses gradient boosting. Finally, to capture the day-ahead aspect of the problem and add a time series feature, I used the previous day’s load (t-24).

Day of week (seven days)

Holiday (yes or no)

Hour of Day (24 hours)

Temperature Reading (hourly)

Previous Day’s Load (t-24)

The bottom of each ISO model page contains some helpful visualizations of the training data. Dash Bootstrap Components make it easy to specify content layout; you can use the row and column functionality to put three equally spaced graphs on the same row:

dbc.Row([dbc.Col(width=4), dbc.Col(width=4), dbc.Col(width=4)])

One of the most helpful visualizations on this row is the scatter plot on the right, which shows the correlation between daily peak electricity demand with temperature. Most plots for each ISO have some degree of a boomerang shape, where peak demand rises with either high or low temperatures, but remains low during shoulder season temperatures.

You can create an interactive scatterplot using Dash Core Components to create a dropdown via dcc.Dropdown, then associate it with a plot by defining a callback function.

Results

How well does each model perform? Depends on the ISO. Mean Absolute Error (MAE) is a standard measure of distance between pairs of observations (predicted demand versus actual). As you can see, some ISOs have a MAE for the month of February 2021 that is quite low (lower is better), considering that total demand is often in the tens of thousands of Megawatts (MW).

CAISO: 455.91

MISO: 2,382.66

PJM: 2,886.66

NYISO: 347.62

ISONE: 522.43

Visually inspecting results for the month of February also reveals how the model captures the daily and weekly seasonality, as well as temperature changes:

However, February is typically a pretty docile month for peak demand (aside from recent events in Texas) because most grids peak during the summer due to AC load. The real test for this model will come when we update the predictions vs. actual plot to see how it performs in July and August 2021, when it will likely be overly conservative in predicting peaks.

Demand Forecasting in the Real World

Peaky Finders is a gentle introduction to ISOs and demand forecasting; ensuring this model performs reliably when the stakes are higher requires introducing more complexity into the model assumptions.

One major area of improvement would be Peaky Finders’ weather features. Because ISO regions are so large, using one central point to represent weather for the entire territory is typically inadequate. This may not be a problem when demand is concentrated in a central area, like New York City. However, when an ISO territory covers multiple states stretching from the East Coast all the way to the Midwest, like PJM, a temperature reading from Philadelphia won’t cut it. For this reason, the Peaky Finders models trained on larger ISOs (PJM and MISO) do not perform as well.

Additionally, the proliferation of distributed energy sources (DERs) complicates load forecasting by making demand flexible and responsive to changes in supply. Some DERs, like rooftop solar, can even generate their own electricity on site and mask the full extent of electricity consumption. For example, on a sunny day in an area with high penetrations of rooftop solar, many customers may be producing and consuming their own electricity instead of drawing from the grid. As a result, ISOs may show a dip in demand during the day when rooftop solar production is high and a spike in the evening when the sun goes down.

Other DERs, such as electrified heating, may change the core assumptions of traditional demand forecasting. As a higher proportion of electricity comes from wind and solar, using electricity for heating in homes and buildings instead of natural gas is increasingly better for the environment. However, this leaves the grid vulnerable to demand spikes in the winter. If a cold snap both increases demand rapidly while also threatening supply, such as what happened in Texas in February, ISOs have to make some challenging decisions. As a result, it is important for demand forecasters to consider the adoption patterns of new electricity-consuming technologies and how they may impact the grid.

As climate change magnifies extreme weather and forces communities to adopt new energy technologies, the nature of electricity demand changes drastically, making demand forecasting harder than ever. The hurdle with using machine learning for critical services like demand forecasting, or sexier use cases like driving a car autonomously, is that it handles 99% of situations extremely well yet struggles when generalizing to edge cases. An odd encounter on the road is problematic for a self-driving car just as an unusually cold winter is problematic for the grid forecasting system. Ensuring the model is helpful in scenarios it hasn’t seen before will become increasingly important and the grid evolves to maximize the potential of renewable energy.