Engineer Features to Enhance Smartphone Battery Life Prediction
Quick Overview
Evaluates battery-life prediction from sparse discharge traces using interpolation and feature engineering. Strong answers implement single- and multi-trace prediction, add contextual features, and match similar devices when history is sparse.
Engineer Features to Enhance Smartphone Battery Life Prediction
Company: Google
Role: Data Scientist
Category: Machine Learning
Difficulty: medium
Interview Round: Technical Screen
##### Scenario
Predict how long a smartphone can keep working given its current battery level, when limited historical data is available.
##### Question
Write code that uses linear interpolation to predict remaining usage time from current battery percentage. Beyond battery level, which additional variables would you engineer to improve prediction accuracy and why? If no historical data from identical phones exists, describe a feature-matching strategy to generate a usable training set.
##### Hints
Think temperature, screen-on time, app mix, battery health; consider similarity search on handset specs.
Quick Answer: Evaluates battery-life prediction from sparse discharge traces using interpolation and feature engineering. Strong answers implement single- and multi-trace prediction, add contextual features, and match similar devices when history is sparse.
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 propose ways to improve prediction accuracy.
Constraints & Assumptions
Each trace is a time-ordered series of elapsed time and battery percentage during continuous usage.
Battery percentage should generally decrease over time, though minor measurement noise may exist.
The current battery percentage may fall between observed trace points or outside the observed range.
Predictions should handle sparse history and missing identical-device data gracefully.
Clarifying Questions to Ask Guidance
What units are used for elapsed time, and how often are battery readings sampled?
Are traces from the same user, same device model, same battery age, or mixed devices?
Is the phone currently charging or in continuous discharge?
What error metric matters most: MAE, MAPE, calibration, or conservative underprediction?
Part 1 - Interpolation Predictor
Provide code or pseudocode for a linear interpolation predictor for a single trace and a multi-trace aggregation.
What This Part Should Cover Guidance
Sort and validate trace points, handle monotonicity issues, and find bracketing percentages.
Interpolate elapsed time at the current percentage and estimate time to zero.
Handle extrapolation, out-of-range percentages, and sparse endpoints carefully.
Aggregate multiple traces using mean, median, weighted average, or nearest-context traces.
Part 2 - Feature Engineering
Propose additional variables to improve battery-life prediction and explain why they help.
What This Part Should Cover Guidance
Include device model, battery health, battery age, OS version, screen brightness, network type, app mix, CPU/GPU load, temperature, charging history, and usage intensity.
Include contextual features such as time of day, location state, foreground app category, and connectivity.
Discuss per-user and per-device personalization.
Mention leakage risks from features unavailable at prediction time.
Part 3 - Matching Without Identical Historical Data
If no historical data from identical phones exists, describe a feature-matching strategy to build a usable training set.
What This Part Should Cover Guidance
Match on device family, battery capacity, OS, battery health, usage context, network, temperature, and app behavior.
Use nearest-neighbor matching, clustering, hierarchical models, or transfer learning.
Weight traces by similarity and recency.
Validate on held-out traces and report uncertainty for sparse matches.
Follow-up Questions Guidance
How would you handle a trace where battery percentage briefly increases?
How would you evaluate prediction quality for very low battery percentages?
How would the approach change if the phone has only one partial trace?