- Name: Shalini Balaram
- Email: shalinib0204@gmail.com
- Affiliation: IIT Madras alumna
This project uses LSTM (Long Short-Term Memory) neural networks to forecast streamflow based on historical rainfall and streamflow data for the Abusu station.
The repository is structured as a reproducible forecasting pipeline: raw rainfall/streamflow inputs are preprocessed into train/validation/test splits, an LSTM model is trained, and evaluation metrics and plots are written to timestamped output folders.
- Rainfall-runoff time-series preprocessing
- Sequence modeling for streamflow forecasting
- Train/validation/test evaluation with saved metrics and plots
- Reproducible command-line experiments with configurable model settings
-
data/: Contains rainfall and streamflow data for Abusu station and catchment attributesAbusu_rainfall.csv: Historical rainfall dataAbusu_streamflow.csv: Historical streamflow dataCatchments.Attributes.xlsx: Catchment attributesprocessed/: Directory for preprocessed data (created automatically)
-
src/: Source codepreprocess.py: Data preprocessing utilitiesmodel.py: LSTM model definitionutils.py: Utility functionsmain.py: Main implementation of the forecasting pipeline
-
run.py: Entry point script to run the forecasting pipeline -
requirements.txt: List of required Python packages -
models/: Directory for model checkpoints (created automatically) -
results/: Directory for evaluation results (created automatically)
- Install the required packages:
pip install -r requirements.txt
- Run the forecasting pipeline with default settings:
python -m src.run
The main script has been placed in the src directory and can be run using the Python module notation:
# Run with default settings (training and evaluation mode)
python -m src.runThe script will:
- Load and preprocess the data from the
datadirectory - Create a train/validation/test split of the data
- Train an LSTM model on the training data
- Evaluate the model on the test data
- Save the model, plots, and metrics to timestamped directories
The script supports two main modes of operation:
# Training and evaluation mode (default)
python -m src.run --mode train_eval
# Prediction mode (requires a trained model)
python -m src.run --mode predict --model_path models/run_YYYYMMDD_HHMMSS/best_model.pt# Change the sequence length (default: 7)
python -m src.run --sequence_length 14
# Force reprocessing of data even if processed data exists
python -m src.run --reprocess# Change the model architecture
python -m src.run --hidden_size 128 --num_layers 3 --dropout 0.3# Modify training hyperparameters
python -m src.run --batch_size 64 --epochs 150 --learning_rate 0.0005 --patience 15# Change output directories
python -m src.run --output_dir my_results --model_dir my_models
# Set random seed for reproducibility
python -m src.run --seed 42# Use GPU if available
python -m src.run --device cudaFor a complete list of options, run:
python -m src.run --helpA typical workflow might look like this:
# 1. Train a model with custom parameters
python -m src.run --hidden_size 128 --sequence_length 14 --epochs 200 --learning_rate 0.0005 --seed 42
# 2. Use the trained model to make predictions
python -m src.run --mode predict --model_path models/run_YYYYMMDD_HHMMSS/best_model.ptReplace YYYYMMDD_HHMMSS with the actual timestamp of your training run.