Monsoon over Kerala prediction is a climate-machine-learning project developed as a BTech final-year project. The repository uses the ERA5 reanalysis dataset to study whether historical geophysical variables can be used to learn useful representations of the pre-monsoon atmosphere and then predict the date of monsoon onset over Kerala.
The project follows a two-stage workflow:
- A self-supervised BYOL model learns robust spatiotemporal representations from climate inputs.
- A downstream regression model uses the extracted features to predict the onset date, with both standard evaluation and Leave-One-Year-Out (LOYO) evaluation.
The repository also contains explainability utilities for inference visualisation, attribution maps, and feature extraction from trained checkpoints.
The aim of this work is to build a data-driven model for Monsoon over Kerala prediction that can:
- learn from multi-channel climate data,
- capture temporal evolution across successive timesteps,
- produce interpretable regression outputs for onset-date prediction,
- evaluate generalisation under both regular validation and year-wise LOYO testing,
- support model interpretability through attribution-based visual analysis.
The main workflow is organised around three stages:
- Data preprocessing and representation learning.
- Regression training and evaluation.
- Explainability, inference visualisation, and feature extraction.
src/training/scripts: Training and evaluation entry points.src/explainability: Inference, attribution, and feature extraction scripts.config: Model and data configuration files.checkpoints: Saved model weights.features: Precomputed feature tensors used by the regressors.results: Evaluation tables, plots, and summary artifacts.outputs: Sample-level explainability figures.
The src/training/scripts directory contains the main files used to run the project.
src/training/scripts/train_byol.py
This script trains the BYOL backbone used to learn climate representations in a self-supervised manner. It reads the project configuration, creates the dataloaders, applies the expected normalisation pipeline, and saves the learned representation model.
The BYOL stage is used to produce transferable features that are later consumed by the regression models.
src/training/scripts/train_delta_regressor_cross_val.py
This script trains the delta sequence regressor on precomputed features using the normal train/validation/test split. It performs hyperparameter search, selects the best configuration, and writes the resulting prediction tables and metrics to results/tables.
Typical outputs include:
- train, validation, and test prediction CSV files,
- a grid-search summary,
- the best hyperparameter JSON file,
- a saved checkpoint for the best regressor,
- per-timestep skill score tables.
src/training/scripts/train_delta_regressor_cross_val_loyo.py
This script performs LOYO evaluation, where each test year is held out sequentially and the model is re-trained using all previous years as additional training data. This is the most important evaluation mode for measuring year-wise generalisation in a climate forecasting setting.
Typical outputs include:
- sequential test prediction CSV files,
- summary JSON and CSV reports,
- top-ranked hyperparameter trials,
- best-trial selection summaries.
The src/explainability directory contains the utilities used for model interpretation and post-training analysis.
src/explainability/full_model_explain.py
This is the main inference-and-explainability entry point. It loads the trained BYOL backbone and the regressor checkpoint, runs inference on the test set, and produces side-by-side visualisations of the input channels and their attribution maps.
The generated images are saved under outputs/sample_XXXXX/ as per-timestep figures.
src/explainability/combined_model.py
This file defines the combined inference pipeline and the model wrapper used for attribution. It contains the backbone, the delta regressor, the feature preparation logic, and the attribution support used by the explainability script.
src/explainability/full_model_extract.py
This script is intended for extracting features from the trained model pipeline and preparing intermediate outputs for further analysis.
config/model_config.ymlis the main configuration file used by the training and evaluation scripts.config/model_config_new_45.ymlis an additional configuration variant used for the BYOL feature pipeline.
The downstream regressors expect feature tensors stored under:
features/<feature_subdir>/train_features.ptfeatures/<feature_subdir>/val_features.ptfeatures/<feature_subdir>/test_features.pt
For this repository, the main feature directory is features/MoK_byol_new_transformer_45/.
Model checkpoints are stored in checkpoints/, including the BYOL backbone checkpoint and the best regressor checkpoint.
The trained checkpoints can be found accessed from the following links:
The results/ directory contains:
- prediction CSV files,
- hyperparameter search summaries,
- LOYO evaluation summaries,
- skill score tables,
- plots and figures generated during analysis.
The outputs/ directory contains sample-wise attribution figures saved by the explainability pipeline.
- Prepare the configuration in
config/model_config.yml. - Train or load the BYOL checkpoint using
src/training/scripts/train_byol.py. - Generate and store feature tensors in
features/MoK_byol_new_transformer_45/. - Train the standard regressor with
train_delta_regressor_cross_val.py. - Run LOYO evaluation with
train_delta_regressor_cross_val_loyo.py. - Use
src/explainability/full_model_explain.pyto generate attribution maps and inference figures.
This project is implemented in Python and depends on common scientific and deep-learning libraries. The conda environment can be set up using the provided environment.yml file:
conda env create -f environment.yml
conda activate MoK_date_predict- Several scripts currently use project-specific absolute paths inside the source code. If you move the repository to a different location, update those paths before running the scripts.
- The regression scripts assume that feature files already exist in the
features/directory. - The explainability script expects trained BYOL and regressor checkpoints to be available in
checkpoints/. - The LOYO script is computationally more expensive than the standard train/validation/test run because it retrains across multiple year splits.
- For the complete methodology, experimental setup, and results discussion, refer to MoK_paper.pdf.
results/tables/*.csvfor evaluation summaries and predictions.results/hyperparams/*.ymlfor run configuration logs.checkpoints/*.pthfor saved model weights.outputs/sample_*/side_by_side_t*_all_channels.pngfor attribution visualisations.