Data Analysis for Engineers/Module 6

Module 6 · Section 3 of 8

Case Study 6.2 - Grid Power Demand Forecasting

Electrical Engineering

A distribution utility needs a 12-month-ahead peak-demand forecast for a franchise area to plan substation capacity. You have 8 years of monthly peak demand (MW). Fit a trend-plus-seasonal model and project the next year.

from sklearn.linear_model import LinearRegression

np.random.seed(102)
months = pd.date_range("2016-01-01", periods=96, freq="MS")   # 8 years, monthly
t = np.arange(96)                                              # 0, 1, 2, ... as a time index
# build the series: linear trend + one seasonal sin/cos pair + noise
demand_mw = (8000 + 11.0 * t
             + 550 * np.sin(2 * np.pi * t / 12)
             + 180 * np.cos(2 * np.pi * t / 12)
             + np.random.normal(0, 140, 96))

# feature matrix: [ time, sin(2*pi*t/12), cos(2*pi*t/12) ] - trend + seasonality
def design(tt):
    return np.column_stack([tt, np.sin(2 * np.pi * tt / 12), np.cos(2 * np.pi * tt / 12)])

model = LinearRegression().fit(design(t), demand_mw)
t_future = np.arange(96, 108)                         # the next 12 time steps
forecast = model.predict(design(t_future))            # apply the same feature transform
future_months = pd.date_range("2024-01-01", periods=12, freq="MS")

print(f"Fitted growth: {model.coef_[0] * 12:.0f} MW/year")   # coef on t is per month; *12 = per year
print(f"Forecast peak next 12 months: {forecast.min():.0f} - {forecast.max():.0f} MW")
print(f"Highest projected month: {future_months[np.argmax(forecast)].strftime('%B %Y')}")

fig, ax = plt.subplots(figsize=(11, 4.5))
ax.plot(months, demand_mw, color="steelblue", label="Historical peak")
ax.plot(future_months, forecast, color="firebrick", marker="o", label="Forecast")
ax.set_ylabel("Peak demand (MW)"); ax.set_title("Monthly Peak Demand - History & 12-Month Forecast")
ax.legend(); plt.tight_layout(); plt.show()

Key Takeaways

  • A simple linear trend plus one sin/cos seasonal pair captures most of a monthly peak-demand series - you don't always need ARIMA.
  • The fitted trend coefficient converts directly to an annual growth rate, which feeds capacity planning and reserve-margin decisions.
  • Always sanity-check the forecast's seasonal peak month against domain knowledge (in most PH franchise areas, the hot dry months of April-May).

58 / 63 sections · Course home · Join the coaching cohort