Skip to content

About

A Bayesian time series study on Paris historical climate data, capturing seasonal dynamics and long-term trends to output 12-month probabilistic temperature forecasts with credible intervals.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Paris Weather Analysis — Time Series & Bayesian Modeling

A time series analysis and Bayesian forecasting project on historical Paris temperature data, exploring long-term trends, seasonality, and producing probabilistic 12-month temperature forecasts with quantified uncertainty.

Overview

This notebook analyzes daily/monthly historical temperature records for Paris to understand long-term warming trends and seasonal cycles, then builds a custom Bayesian regression model (trend + seasonality + lag-12 dependence) to forecast future average daytime temperatures, complete with credible intervals.

Dataset

Source file: paris-historical-temperature.csv

Column Description
observ_date Date of observation
avg_day Average daytime temperature (target variable)
avg_night Average nighttime temperature
max_day Maximum daytime temperature
max_night Maximum nighttime temperature
  • Observations: 1,462
  • Time unit: Monthly
  • Chosen because it's a chronologically ordered, regularly-spaced series well suited to trend/seasonality decomposition, ACF/PACF analysis, stationarity testing, and Bayesian modeling of temperature as a probabilistic variable.

Workflow

1. Data Preprocessing

  • Parses observ_date to datetime, sorts chronologically, and sets it as the index.
  • Checks for missing values, duplicate rows, and time-interval consistency.
  • Detects and removes outliers in avg_day using the IQR method, then interpolates the gaps.
  • Engineers features: lag_1, lag_12 (same month, prior year), month, year.

2. Exploratory Time Series Analysis

  • Plots the raw time series and observes a strong yearly seasonal cycle with a slight long-term upward trend.
  • Runs an additive seasonal decomposition (period = 12) to separate trend, seasonal, and residual components.
  • Examines ACF/PACF plots — strong seasonal correlation at lags 12/24/36 and early-lag autoregressive structure, supporting an AR/seasonal modeling approach.
  • Flags extreme values (±2 standard deviations) as likely unusual weather events or measurement anomalies.

3. Bayesian Modeling

Builds a custom Bayesian regression model (using PyMC) with the structure:

avg_day(t) = α + β·t + γ₁·sin(2πt/12) + γ₂·cos(2πt/12) + φ·avg_day(t−12) + ε
Term Meaning
alpha Baseline temperature level
beta Long-term monthly trend
gamma1, gamma2 Strength/phase of the yearly seasonal cycle
phi Dependence on the same month in the previous year
sigma Unexplained variability
  • Fit via MCMC sampling (pm.sample, 2000 draws, 1000 tuning steps, target_accept=0.95).
  • Diagnosed with arviz summary tables and trace plots.
  • In-sample fitted values are compared against observed data to check model fit.

4. Forecasting

  • Projects 12 months ahead using posterior mean parameter estimates, feeding forecasts back in for the lag-12 term.
  • Performs an out-of-sample backtest: trains on all but the last 24 months, forecasts that held-out period using posterior samples, and plots the forecast mean with a 95% credible interval against actual values.
  • Evaluates forecast accuracy with MAE and RMSE.

Key Findings

  • The series is dominated by strong, consistent yearly seasonality and a gradual warming trend, making it non-stationary in its raw form.
  • The Bayesian model captures both the seasonal cycle and trend well, with in-sample fitted values closely tracking observed temperatures.
  • Backtested forecasts track actual held-out temperatures closely, preserving the seasonal pattern and trend.
  • Unlike traditional point-forecast models, the Bayesian approach provides credible intervals that quantify forecast uncertainty.

Requirements

  • Python 3.x
  • Packages:
    pandas
    numpy
    matplotlib
    statsmodels
    pymc
    arviz
    scikit-learn
    

Install with:

pip install pandas numpy matplotlib statsmodels pymc arviz scikit-learn

Running the Notebook

  1. Place paris-historical-temperature.csv in the same directory as the notebook (semicolon-delimited).
  2. Open and run ParisWeather.ipynb cell by cell.
  3. Note that the Bayesian model fitting cells (MCMC sampling) can take several minutes depending on your hardware.
  4. Review the plots (time series, decomposition, ACF/PACF, outliers, fitted vs. observed, forecasts) and printed model summaries / error metrics as you go.

Notes

  • The forecasting section refits the Bayesian model on a train/test split (holding out the last 24 months) purely for backtesting; the standalone 12-month forecast earlier in the notebook uses the model fit on the full dataset.
  • The lag-12 term means forecasts beyond the first 12 months would need previously forecasted values as inputs, which can compound uncertainty over longer horizons.

About

A Bayesian time series study on Paris historical climate data, capturing seasonal dynamics and long-term trends to output 12-month probabilistic temperature forecasts with credible intervals.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages