Prompt
How do I set up a recovery scoring engine for measuring engagement and trend changes from wearable data?
Latest observation
A good recovery scoring engine for wearable data usually has 5 parts:
- Ingest raw signals
- Normalize and clean them
- Convert them into features
- Compare today vs. your personal baseline
- Turn the result into a score + trend indicator
Here’s a practical setup.
1) Define what “recovery” means
Decide what signals reflect recovery for your use case. Common wearable signals:
- Resting heart rate (RHR)
- Heart rate variability (HRV)
- Sleep duration and sleep stages
- Respiratory rate
- Skin temperature deviation
- Activity load / strain
- Steps or movement volume
- Subjective readiness or soreness, if available
A recovery score should usually answer:
- How recovered am I right now?
- Is my recovery improving or worsening over time?
- Is this change abnormal for me?
2) Build the data pipeline
Data ingestion
Pull daily or intraday data from the wearable API into a time-series store or warehouse.
Typical tables:
user_profiledaily_metricsintraday_heart_ratesleep_sessionsactivity_sessions
Data cleaning
Wearables are noisy. Handle:
- Missing days
- Duplicates
- Outliers
- Device swaps
- Partial wear time
- Time zone shifts
Useful rules:
- Ignore days with too little wear time
- Winsorize extreme values
- Use rolling medians for unstable metrics
- Mark low-confidence data separately
3) Create a personal baseline
Recovery is best measured relative to the user, not a population average.
For each metric, compute a baseline over a rolling window, such as:
- 14 days for short-term responsiveness
- 28 days for a more stable baseline
- 90 days for long-term seasonality
Example baseline features:
baseline_hrv = median(HRV over last 28 days)baseline_rhr = median(RHR over last 28 days)baseline_sleep = median(sleep duration over last 28 days)
Also compute variability:
- standard deviation
- median absolute deviation
- percentile bands
This helps normalize each metric into a comparable scale.
4) Convert metrics into normalized recovery features
Turn each raw metric into a standardized score.
Example directionality:
- Higher HRV = better recovery
- Lower RHR = better recovery
- More sleep = better recovery
- Lower respiratory rate deviation = better recovery
- Lower training load after hard effort = better recovery
You can transform each metric into a z-score or percentile relative to the user’s baseline.
Example normalized features
hrv_score = (HRV_today - baseline_hrv) / baseline_hrv_stdrhr_score = (baseline_rhr - RHR_today) / baseline_rhr_stdsleep_score = clamp(sleep_hours_today / baseline_sleep_hours, 0, 1.5)load_penalty = normalize(training_load_today)
Then optionally rescale each to 0–100.
5) Create a composite recovery score
A simple weighted formula works well at first.
Example
Recovery Score =
0.35 * HRV_component
+ 0.25 * RHR_component
+ 0.20 * Sleep_component
+ 0.10 * Respiratory_component
+ 0.10 * Load_component
Where each component is scaled 0–100.
Important
Weights should be:
- user-specific if possible
- learned from historical data later
- validated against outcomes like fatigue, illness, performance, or self-reported readiness
6) Detect trend changes
A recovery score alone is not enough. You also want trend detection.
Useful trend methods
- Rolling average slope over 7/14/28 days
- Exponentially weighted moving average (EWMA)
- Change-point detection
- Control charts
- CUSUM
- Anomaly detection against baseline
Example trend signals
short_term_trend: 7-day slope of recovery scoremedium_term_trend: 28-day slopetrend_shift_flag: 1 if score drops significantly below baselinevolatility: rolling standard deviation of score
Interpretation:
- Score high but trending down = early warning
- Score low but improving = recovering
- Sudden drop = possible overreaching, poor sleep, illness, stress
7) Build a state machine or classification layer
Instead of only returning a number, convert the score into labels:
- Recovered
- Stable
- Fatigued
- Overreached
- At risk
- Recovering
Example logic:
- Score > 75 and trend positive →
Recovered - Score 50–75 and stable →
Stable - Score < 50 and falling →
Fatigued - Score drops > X points in 3 days →
At risk
This makes the output easier to act on.
8) Add confidence / data quality
Every score should include confidence.
Examples:
- High confidence: full sleep + HRV + RHR data available
- Medium confidence: missing one metric
- Low confidence: missing sleep or wear time is incomplete
You can output:
recovery_scoretrendconfidenceexplanation
9) Validate against outcomes
To know if the engine works, compare it with:
- self-reported readiness
- workout performance
- illness onset
- soreness
- HR/pace drift
- missed sessions
- perceived exertion
Metrics to evaluate:
- correlation with readiness
- precision/recall for low-recovery alerts
- calibration of score bands
- false positive rate
- stability over time
10) Recommended architecture
A practical production design:
Data layer
- Wearable API ingestion
- Time-series DB / warehouse
Feature layer
- Daily feature generation job
- Baseline computation
- Trend computation
Scoring layer
- Rule-based score v1
- ML model v2 if enough labels exist
Serving layer
- API endpoint returning score + trend + confidence
- Dashboard / mobile app display
- Alerting system for abnormal drops
11) Simple starter formula
If you want a first version quickly:
Recovery Score = 100
- 25 * z(RHR above baseline)
- 30 * z(HRV below baseline)
- 20 * sleep deficit ratio
- 15 * activity load excess
- 10 * respiratory deviation
Then clip to 0–100.
Trend:
Trend = 7-day EMA(Recovery Score) - 28-day EMA(Recovery Score)
If Trend is negative, recovery is worsening.
12) Example output
{
"user_id": "123",
"date": "2026-10-21",
"recovery_score": 68,
"trend": "declining",
"trend_delta_7d": -6.2,
"confidence": "high",
"flags": ["sleep_debt", "elevated_rhr"]
}
13) If you want to use machine learning later
Once you have labels like “felt recovered” or “poor workout day,” you can train:
- gradient boosting trees
- logistic regression
- temporal models
- anomaly detection models
Inputs:
- recent HRV, RHR, sleep, load, respiratory rate
- rolling averages and slopes
- previous-day values
- seasonality features
- missingness indicators
Targets:
- readiness
- fatigue
- illness
- performance drop
14) Key design principles
- Use personalized baselines
- Prefer trends over single-day values
- Include data quality/confidence
- Keep the first version simple and interpretable
- Validate against real outcomes
- Update baselines over time, not once
If you want, I can also give you:
- a Python implementation,
- a database schema, or
- a full scoring formula with thresholds and trend rules.