Battery Life Prediction with Sparse History
Problem
You are given sparse discharge traces that record battery percentage over elapsed time for prior usage sessions. Predict the remaining usage time for a phone at its current battery percentage using linear interpolation. Then:
-
Provide code for the interpolation-based predictor (single trace and multi-trace aggregation).
-
Propose additional variables (features) you would engineer to improve prediction accuracy and explain why.
-
If no historical data from identical phones exists, describe a feature-matching strategy to build a usable training set from similar devices and contexts.
Assumptions
-
Each discharge trace is a time-ordered series of (elapsed_time, battery_percent) during continuous usage (no charging within a trace).
-
Battery percent decreases monotonically with elapsed time; minor noise can be smoothed or handled by sorting/deduping.
-
If a trace does not reach 0%, we may extrapolate the last segment linearly to estimate time at 0%.