Forecast tomorrow’s electricity demand

Your meters already record the daily peak demand. Spavik reads that history and forecasts tomorrow’s peak, so you can plan production and purchases a day ahead.

Returns
Tomorrow’s peak demand, in megawatts
Language
Python

In your app

San Francisco, tomorrow

1,040 MW

tomorrow peak demand

Display tomorrow’s expected peak in the planning view.

The data you need

One row per day, in date order. Spavik reads that history to forecast the next value.

Daily peak electricity demand for San Francisco, in megawatts.

ColumnRoleMeaning
dateDateOne row per day
peak_mwPredictedHighest demand of that day, in megawatts

The code

A complete, commented script. Set SPAVIK_API_KEY in your server environment, never in browser code.

electricity-demand-forecast.py Python
from spavik import Spavik
 
# Set SPAVIK_API_KEY in your server environment.
spavik = Spavik()
 
# sf_peaks.csv: date, peak_mw.
# One row per day: the highest demand of that day.
history = "sf_peaks.csv"
 
# Check forecasts against past days before using them.
report = spavik.backtest(
    history,
    target="peak_mw",
    horizon=1,
    timestamp="date",
)
print("Backtest:", report["assessment"]["message"])
 
# A period is one day: horizon=1 forecasts tomorrow.
forecast = spavik.forecast(
    history,
    target="peak_mw",
    horizon=1,
    timestamp="date",
)
 
# Show tomorrow's expected peak in the planning view.
peak = forecast.points[0]["peak_mw_prediction"]
print(f"San Francisco, tomorrow's peak demand: {peak:,.0f} MW")

How it works

  1. 1

    Check past days

    backtest() replays your history for free and shows how forecasts would have done.

  2. 2

    Forecast the next day

    forecast() reads your history and returns tomorrow’s value. No model to keep.

  3. 3

    Show it in your app

    Display the value where your team plans. One credit per call with horizon=1.

Questions

How much history do I need?

One row per day, sorted by date, with at least as many points as the periods you ask for, and preferably several times more. backtest() replays your history for free to show how forecasts would have done.

What does it cost?

backtest() is free. forecast() keeps no model and costs the requested horizon per call, all series included: forecasting tomorrow with horizon=1 costs one credit.

Try it on your own data

Get an API key. Checking your data is free.