This repository contains code, data utilities, and documentation for a hybrid battery State-of-Health (SoH) and Remaining Useful Life (RUL) estimator that combines a Square-Root Dual Unscented Kalman Filter (SR-DUKF) for robust state and parameter estimation with an LSTM-based Open-Circuit-Voltage (OCV) model.
Contents
cleaned_dataset/— per-discharge CSV files andmetadata.csvdescribing EKF parameters and labels.scripts/— training, inference, EKF, and validation scripts (seescripts/README.mdor inlinescriptsdocstrings).outputs/— generated models, validation reports, and plots.docs/anddocumentation/— detailed reports, validation summaries, and quick references.
Key files
scripts/train_dekf_lstm.py— main training pipeline that trains the OCV-LSTM model.scripts/infer_ukf.py— single-file inference using UKF + trained LSTM OCV model.scripts/ukf_soc.py— UKF implementation.scripts/metadata_loader.py— utilities to load per-file UKF parameters fromcleaned_dataset/metadata.csv.outputs/eda/hybrid_lstm_model.keras— canonical trained OCV model (if present).
Quick start
- Create a Python environment and install dependencies (see
requirements.txt):
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Run a short training run (example):
# train on a subset (set --max-files to limit); tune epochs/batch/seq-len as needed
python3 scripts/train_dekf_lstm.py --max-files 200 --epochs 10 --batch-size 64 --seq-len 50- Run inference on a single discharge file:
python3 scripts/infer_ukf.py --input-file cleaned_dataset/data/00001.csv --model outputs/eda/hybrid_lstm_model.keras- Run the validation workflow (example uses 100 random files):
python3 scripts/test_metadata_based_model.py --n-samples 100 --out-dir outputs/edaRepository structure
bms/
├─ cleaned_dataset/
│ ├─ metadata.csv
│ └─ data/ (per-discharge CSVs: 00001.csv ...)
├─ scripts/
│ ├─ train_dekf_lstm.py
│ ├─ infer_ukf.py
│ ├─ ukf_soc.py
│ └─ metadata_loader.py
├─ outputs/
│ └─ eda/ (models, predictions, reports)
├─ documentation/
└─ README.md
Model & outputs
- Trained models are saved under
outputs/eda/by default (filehybrid_lstm_model.keras). - Validation reports and per-file predictions are saved into
outputs/eda/during validation runs.
Contributing and development notes
- Use
scripts/utilities to reproduce training and validation. The code is organized for research workflows; small edits and experiments are expected. - Tests and validation harnesses are in
scripts/anddocumentation/.
Or use the GitHub CLI (if installed and authenticated):
# interactive create + push
gh repo create bms-soh-estimator --public --source=. --remote=origin --pushLicense
- This project is released under the MIT License. See
LICENSEfor details.
Where to go next
- Train model to predict soh and rul based on soc and temperature.
- make an web app to take live data and predict based on that.
- Improve the model accuracy.