Skip to content

marinova-teddy/Forecasting-ML-Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Forecasting-ML-Model: Bias-Correction via Linear Regression

Model Description

This project implements a linear-regression model that learns to adjust (bias-correct) multiple numerical weather prediction (NWP) forecasts in order to better match real-world observations. Rather than relying on a single forecast, the model linearly combines seven separate forecast sources—each representing a different ensemble or deterministic run—into a single, corrected estimate.

Features

  • Input: At each hourly timestamp, the model ingests seven independent forecast values (e.g., output from different weather models or ensemble members).
  • Forecast source order: ec, ec-ens, ecsr, ecsr-ens, gfs, gfs-ens, icon]
  • Output: A single predicted value, which is intended to approximate the actual measured wind-power production for that same hour.

Because each forecast source can have its own systematic under- or over-prediction bias, the model learns one weight per source plus a constant offset. In other words, it finds an optimal linear combination of the seven forecasts to minimize the discrepancy from the measured data.

Training Workflow

  1. Data Alignment:

    • Two aligned tables:
      • A multi-column table of hourly forecasts (one column per source).
      • A single-column table of corresponding actual measurements.
    • Both tables share the same datetime index, ensuring each row represents the same hour in both forecast space and reality.
  2. Train/Test Split (Time Series):

    • The first 80 % of the chronological data is used for training; the last 20 % is held out for final evaluation.
    • No random shuffling—this preserves the time order so that test results reflect “future” performance.
  3. Model Architecture:

    • A very simple neural network in Keras/TensorFlow:
      • Single Dense layer with seven input features and one output unit, using an explicit linear activation (activation='linear').
    • In effect, this layer computes
      $$ \hat{y} = w_1 x_1 + w_2 x_2 + \dots + w_7 x_7 + b $$
      exactly the same as ordinary least-squares linear regression, but implemented within Keras for easy integration of callbacks and GPU acceleration if needed.
  4. Optimization:

    • The model is trained to minimize Huber loss (with δ = 0.85) between its predicted value and the actual measurement, trading off squared-error sensitivity near zero residuals with absolute-error robustness in the tails.
    • We use the Adam optimizer over multiple epochs, tracking both training and validation loss to confirm convergence.
    • Two callbacks enhance training:
      • ReduceLROnPlateau: reduce the learning rate by a factor when validation loss plateaus.
      • ModelCheckpoint: save the best model weights (by val_loss) to disk.
    • A fixed maximum of epochs is set, with reduction of LR and checkpointing ensuring efficient and reliable convergence.
  5. Evaluation:

    • After training, the model is evaluated on the final 20 % test set to report test-set Mean Absolute Error (MAE) and Mean Squared Error (MSE).
    • The learned weights (one per forecast source) and bias term can be inspected to see each source’s relative contribution.

Summary

  • We take seven different 24 h-ahead forecasts as input features—each from a distinct weather model or ensemble.
  • A single-layer Keras model (i.e. straight-line regression) learns to combine these forecasts into one corrected estimate.
  • By minimizing Huber loss (δ = 0.85) via Adam and leveraging callbacks for learning-rate reduction and best-model checkpointing, the training is both robust to outliers and efficient.
  • The end result is a lightweight, interpretable bias-correction that improves on any single forecast source by leveraging multiple, parallel predictions.

About

A linear ML model in Python forecasting wind production by wind turbine infrastructure based on historical and forecasted weather data.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors