Skip to content

Temporal & Calendar

Temporal and calendar features encode “when” a price observation occurs. Electricity prices follow strong daily, weekly, and seasonal patterns, and these features allow the models to learn those rhythms.

Cyclical Encoding

Time features like hour-of-day or day-of-week are circular: hour 23 is close to hour 0, December is close to January. Standard integer encoding (0, 1, 2, …, 23) treats hour 0 and hour 23 as maximally distant, which misrepresents their true proximity.

EPF uses sin/cos encoding to preserve circular continuity. Each time dimension is projected onto a unit circle:

feature_sin = sin(2π × value / period)
feature_cos = cos(2π × value / period)

Hour of Day

Period: 24 hours

hour_sin = sin(2π × hour / 24)
hour_cos = cos(2π × hour / 24)

At hour 0: sin=0, cos=1. At hour 6: sin=1, cos=0. At hour 23: sin≈−0.26, cos≈0.97 — correctly close to hour 0.

Day of Week

Period: 7 days

dow_sin = sin(2π × day_of_week / 7)
dow_cos = cos(2π × day_of_week / 7)

Captures the weekly cycle: weekday prices are typically higher than weekends due to industrial demand.

Month of Year

Period: 12 months

month_sin = sin(2π × month / 12)
month_cos = cos(2π × month / 12)

Captures seasonal patterns: summer cooling demand, winter heating, spring hydro availability.

Week of Year

Period: 52 weeks

week_sin = sin(2π × week / 52)
week_cos = cos(2π × week / 52)

Provides finer seasonal resolution than monthly encoding.

Binary Calendar Features

Weekend Indicator

is_weekend = 1 if Saturday or Sunday, else 0

Weekend demand drops significantly (industrial shutdown), causing lower prices and different daily profiles.

Holiday Indicator

is_holiday = 1 if Spanish national holiday, else 0

Spanish national holidays included:

  • New Year’s Day (January 1)
  • Epiphany (January 6)
  • Labour Day (May 1)
  • Assumption (August 15)
  • National Day (October 12)
  • All Saints’ Day (November 1)
  • Constitution Day (December 6)
  • Immaculate Conception (December 8)
  • Christmas Day (December 25)

Easter-dependent holidays (Good Friday, Easter Monday) are computed dynamically using the holidays library when available.

Holidays show demand patterns similar to weekends, with reduced industrial consumption.

Extended Calendar Features

Bridge Day Detection

is_pre_holiday = 1 if tomorrow is a holiday
is_post_holiday = 1 if yesterday was a holiday

Bridge days (days between a holiday and a weekend) often show reduced activity as workers take extended breaks.

Vacation Periods

is_christmas_period = 1 if December 23 – January 6
is_august = 1 if August

These capture extended low-demand periods:

  • Christmas period: Industrial shutdown, many businesses closed
  • August: Traditional Spanish vacation month with reduced economic activity

Direct Prediction Features

In the direct prediction framework, temporal features exist in two forms:

  1. Origin-time features: origin_hour_sin/cos, origin_dow_sin/cos, origin_month_sin/cos, origin_is_weekend — encode when the forecast is being made
  2. Target-time features: target_hour_sin/cos, target_dow_sin/cos, target_is_weekend — encode what time the prediction is for

This separation allows the model to learn: “When predicting at 10:00 on Tuesday for a target at 14:00 on Thursday, the expected price is…”

The hours_ahead feature provides the distance between origin and target, completing the temporal context.