Battery Lifetime Prediction
Millions of EV batteries will retire with plenty of life left for grid storage, if you can tell which ones. I built a pipeline that predicts remaining lifetime from usage and physical degradation signals, training on a quarter of the expensive data.
- Role
- ML engineer · designed and built the pipeline
- When
- 2025
- Stack
- Python · CatBoost · XGBoost · Optuna · scikit-learn
- Target
- Lifetime in equivalent full cycles
Good predictions need data that is expensive to make
A retired EV battery might have years of useful life in stationary storage, or it might be close to failing. Testing each pack is slow and expensive, so the decision has to come from a model.
Two things make that hard. Purely data-driven models learn correlations that break on batteries used differently from the training set. And labelled lifetime data is costly to produce, whether from long cycling tests or heavy electrochemical simulation. So the questions were: which physical signals make the model generalize, and how little data can it learn from?
Small data in, checked at every step
Inputs
What: Statistics of each battery’s current profile (percentiles, mean, spread, skew, rest time, throughput, start voltage, charge fraction), plus three physical degradation modes: loss of lithium inventory (LLI) and loss of active material at each electrode (LAM_PE, LAM_NE).
Why: Usage tells the model how a cell was treated; degradation modes tell it what that did to the chemistry. The physics features carry the signal that a purely statistical model has to guess at.
Making the search space actually searchable
The subset search decides which of 53 data segments (9,650 samples) to train on, with at most 25% of the data allowed. The first version gave Optuna one include/exclude switch per segment. That’s 253 combinations, and since each switch is a coin flip, a typical trial picks about half the segments: far over the cap. Almost every trial was wasted.
I rewrote the search as two decisions: how many segments to take (k between 2 and 13, computed from the cap) and a priority score for every segment; the top-k are kept. Every trial is valid by construction, and Optuna’s TPE sampler can learn gradual preferences (“segment 17 tends to help”) instead of on/off guesses.
How much data is enough?
Values tagged prelim. are placeholders, not yet measured on the final held-out set, and will be replaced with the real results.
Why gradient-boosted trees for the surrogate: the data is small and tabular, where CatBoost and XGBoost are hard to beat and train in seconds, which matters inside a search loop that runs hundreds of trials.
What I took away: constraints belong in the parameterization, not the penalty. Make invalid states unrepresentable and the optimizer gets smarter for free.
Working on ML for energy, batteries or small-data problems? I’d like to hear about it.