Skip to content

feat: density-based activity classifier and data import/export#1

Merged
JanJetze merged 2 commits intomasterfrom
feat/classifier-v2-density-walking
Mar 5, 2026
Merged

feat: density-based activity classifier and data import/export#1
JanJetze merged 2 commits intomasterfrom
feat/classifier-v2-density-walking

Conversation

@JanJetze
Copy link
Copy Markdown
Owner

@JanJetze JanJetze commented Mar 5, 2026

Summary

  • Density-based walking detection: replaces the fragile 36-consecutive-window requirement with a rolling 5-minute density check (5+ windows with hz ≥ 1.5). Tolerates accelerometer throttling gaps that previously prevented walking detection entirely.
  • Sticky cycling exit: requires hz ≥ 2.0 for 8 consecutive windows to exit CYCLING, filtering false step events from road/bike vibration (0.4–1.8 Hz).
  • 30-second evaluation interval: aligned with the step frequency tracker's 30s sliding window. Each reading is now independent (was 83% overlapping at 5s). Reduces battery usage ~6x.
  • DB migration v2→v3: consolidates existing 5s sensor windows into 30s by keeping highest-variance window per slot.
  • JSON data export/import: complete export including sensor windows, with import for data migration between app variants.

Validated against real sensor data

Activity Expected Detected
Walk (Mar 5) ~12:40–13:00 12:43–13:00 (17 min)
Bike ride (Mar 5) ~15:45–16:45 16:00–16:59 (59 min)
Chores/indoor No detection None (zero false positives)

Test plan

  • All 748 unit tests pass
  • Debug APK builds successfully
  • Installed on device, migration ran, activities display correctly
  • Verify walking detection on a new real walk
  • Verify cycling detection on a new real ride
  • Verify no false walking from indoor chores over a full day

🤖 Generated with Claude Code

JanJetze and others added 2 commits March 5, 2026 21:39
Export now includes sensor windows alongside steps, transitions, and
cycling sessions. Import parses the same JSON format and batch-inserts
all records, enabling data migration between app variants (e.g.
production → dev) without raw DB access.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the consecutive-window walking classifier with a density-based
approach that counts walking-quality windows (hz >= 1.5) within a
5-minute rolling window. This tolerates accelerometer throttling gaps
that previously broke walking detection entirely.

Key changes:
- Walking entry: 5 windows with hz >= 1.5 in 5 min (was: 36 consecutive)
- Walking exit: density drops below 2, or 2 min still grace period
- Cycling entry: 6 consecutive windows (was: 2) + 60s duration gate
- Cycling exit: 8 consecutive windows with hz >= 2.0 (filters road
  vibration false step events at 0.4-1.8 Hz)
- Evaluation interval: 30s (was: 5s), aligned with step frequency window
- Accelerometer buffer: 150 samples / 30s (was: 75 / 15s)
- DB migration v2→v3: consolidates existing 5s sensor windows into 30s
  by keeping highest-variance window per 30s slot

Validated against real sensor data: correctly detects a 17-min walk and
a 60-min bike ride with zero false positives from indoor chores.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@JanJetze JanJetze merged commit 5bb1d86 into master Mar 5, 2026
1 check passed
@JanJetze JanJetze deleted the feat/classifier-v2-density-walking branch March 5, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant