Design a Motion-Sensor Activity Model and Clean Training Data
Turn irregular phone-motion recordings into leakage-safe training windows, compare temporal models, and serve versioned activity predictions.
Problem statement
An original-author Google L5 interview report says an ML round asked the candidate to match a model to user-motion-tracking data and clean that data for training; the interviewer reminded the candidate of LSTMs. The report does not specify a prediction target, sensors, labels, or model scores.
The activity-classification task and all numerical targets below are exercise assumptions.
For this exercise, assume opted-in phone users provide timestamped accelerometer and gyroscope readings. A service assigns each completed eight-second motion window one activity label: stationary, walking, or running, and returns the label with model version and quality status.
Reviewed sessions from consenting users supply training labels. Readings can be missing, duplicated, out of order, recorded at irregular rates, or rotated by phone orientation. Labels around activity transitions can be uncertain.
Design the data-quality and labeling path, leakage-safe dataset construction, model choice and evaluation, and a bounded inference/release path. A recording may be excluded from training after consent is revoked; past model handling follows a documented retraining policy rather than an instant-unlearning claim.
Preserve an explicit UNKNOWN result when a window is unusable or confidence is insufficient. Do not infer precise location, identity, health status, or a continuous GPS track. A recurrent model is a candidate to assess, not a required answer.
What to build
- Accept opted-in timestamped motion sessions with stable identity and observable validation outcomes; do not admit a revoked or unusable session into a new training snapshot.
- Create reproducible labeled windows after timing, missing-data, orientation, and label checks; retain enough lineage to audit exclusions and prevent user/session overlap across evaluation splits.
- Compare temporal model candidates against a simple baseline on the same approved split and activity metrics, including per-class and device/orientation slices.
- Return a versioned activity or explicit UNKNOWN/failure for a completed window, and release or roll back a tested model package without silently changing historical results.
At scale
- For this exercise, assume 50 Hz nominal sampling on six accelerometer/gyroscope channels, eight-second windows with a four-second stride, 40,000 concurrently active opted-in devices at peak, and approximately 10,000 completed windows per second. Sample at most one million reviewed windows per day for training.
- For this exercise, the classifier should finish within 200 milliseconds p95 on the reference serving host, use at most 64 MB per model replica, and make a result available within 500 milliseconds p95 after a complete window is accepted. If the system cannot meet that target, expose UNKNOWN or an explicit unavailable outcome rather than a stale label.
- For this exercise, advance a model only if an untouched user-and-session-disjoint holdout achieves macro F1 at least 0.88 and recall at least 0.80 for each activity, with reported performance by device family and orientation. Development measurements select candidates but cannot themselves authorize release.
- For this exercise, retain accepted raw sessions for seven days and immutable dataset manifests and evaluation lineage for one year. Acknowledged consent revocation fences all future training snapshots; existing approved releases follow a documented review and retraining policy.