Calgary, Alberta · Real historical retail data · 2021–2026

From gasoline-price data to better decisions.

Explore a fully documented machine-learning workflow and use our actual trained Linear Regression model to forecast the next recorded weekday price. All results and downloads work offline.

1,516 recorded prices7 lag-based features303 validation days
Selected model
Linear Regression
Lowest validation MAE
Model MAE
3.320 ¢/L
303 later observations
Previous-price baseline
3.653 ¢/L
9.1% MAE reduction
Gasoline refuelling scene

Collect trustworthy prices

Observed Calgary unleaded retail prices. Weekends were not created or interpolated.

Calgary skyline at sunset

Translate data into decisions

Understand price persistence, volatility and next-recorded-day forecasting limitations.

Vehicles travelling through the Canadian landscape

Support practical operations

Inform fuel budgeting and purchasing with human oversight.

01 — Data Overview, Wrangling & Transformation (DP1–DP3)

DATA COLLECTION

Original source

1,516 recorded weekday gasoline prices from Jan 1, 2021 to Oct 23, 2026. Units: cents/litre. Source licence must be confirmed prior to public redistribution.

DP1 · EXPLORE

Inspect quality

Confirm dates, 0 missing prices, 0 duplicate dates, extremes and time trends; preserve original data.

DP2 · PREPARE

Historical features

Lags 1, 2, 3, 5; previous-five rolling mean/std; last price change. Each feature uses earlier records only.

DP3 · MODEL-READY

Scale and split

1,208 earlier training rows (Jan 8, 2021–Aug 26, 2025), then 303 validation rows (Aug 27, 2025–Oct 23, 2026). No shuffling. Training-only z-score scaling.

Historical price series

Weekday observations only; no synthetic weekend data.

Training / validation split

Training: 1,208 / 80%Validation: 303 / 20%

Selected features, X

lag_1 lag_2 lag_3 lag_5 rolling_mean_5 rolling_std_5 change_lag1_vs_lag2

Target y: price for the next recorded date, ¢/L. First five rows do not have complete feature history.

02 — Model training

Trained Linear Regression, Decision Tree, Random Forest, Gradient Boosting and an additional Ridge Regression. Compared each with a last-known-price baseline. Simple models are often effective because prices persist from one recorded day to the next.

ModelMAE (¢/L)RMSEMedAERMSLE

03 — Independent chronological validation

Actual versus predicted prices

Actual (dark) and Linear Regression prediction (blue) on 303 later dates.

Forecast error, every model

Lower is better. Linear Regression ranked first by MAE (3.320 ¢/L), while Ridge ranked first by RMSE.

Interpretation: This validation set was used to select the model. Confirm performance on a new, untouched later test period before real-world deployment.

04 — Interactive forecasting application

Enter five past recorded prices

Provide dated historical observations in ascending order (oldest first). Only previously observed prices are used. Weekend dates are not accepted because the source contains weekday observations.

Enter or load five dated prices, then select Predict.

The seven engineered features are standardized with training-set means and standard deviations and evaluated with the saved Linear Regression parameters. The 90% empirical uncertainty band uses the 90th percentile of absolute errors on the 303 historical validation days. It is not a calibrated guarantee for a changed market.

How predictions work

  1. Sort and validate five strictly increasing, weekday-only historical dates.
  2. Build lag 1, 2, 3 and 5 from the five entered prices.
  3. Calculate previous-five mean, standard deviation (population), and lag 1 minus lag 2.
  4. Apply training-only standardization and the actual fitted model parameters.
  5. Show the next weekday date (Monday after Friday) and predicted price.

Forecast horizon: the next recorded weekday—not an arbitrary calendar day. Excludes holiday and data-provider reporting exceptions; this app assumes Monday–Friday cadence. The estimate is not a guaranteed pump price.

Prediction range: The displayed 90% interval is a descriptive validation-error band, not a formal conditional confidence or prediction interval. Large shocks can exceed it.

05 — AI governance and deployment

Governance checklist

Deployment readiness

Operational concept: record each new observed weekday price; refresh inputs; forecast the next recorded day; log predictions and later compare them with actual prices.

Monitor: trends in error and market regime change. Investigate retraining if rolling error consistently exceeds the baseline.

Control gate: Dataset licensing and independent post-selection testing remain open prior to public or commercial deployment.

06 — Historical report generator

Download date-filtered fuel-price history

Select a recorded date range to export historical observations and, where available, saved validation predictions and forecast errors.

Observations are real records, never filled weekends.

Report coverage

Raw history: 1,516 actual observations (Jan 2021–Oct 2026). Validation: predictions for 303 later observations (Aug 2025–Oct 2026). The historical report separates actuals from saved model predictions and shows missing predictions as blank for earlier dates.

Forecast target: next recorded weekday, not arbitrary dates far into the future. Values use cents per litre.

07 — Download all project files

All CSV files and the original trained-model archive are embedded in this standalone HTML. Downloads work without internet or a web server.

To review independently, compare exported figures against the original dataset and obtain human approval before publication.