Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Kaggle Notebook

🚴 Activity Type Classifier

Classify workout types (run / bike / mountain bike / walk) from real sensor data
Built on 50,000+ real Endomondo workouts


📌 Problem Statement

Given GPS + heart rate + altitude sensor data from a workout,
can we automatically classify what sport the athlete was doing?
This is a core feature in every fitness platform — Strava calls it "Sport Detection".


📊 Dataset

  • Source: FitRec Dataset — Kaggle
  • Origin: Real Endomondo user workouts (UCSD FitRec Project, WWW 2019)
  • Raw size: 250,000+ workouts with time-series sensor arrays
  • Used: 50,000 workouts, filtered to top 4 sport types
  • Format: JSONL with single-quote encoding (required ast.literal_eval parser)

🔧 Feature Engineering

Raw data = time-series arrays per workout. Extracted statistical features:

Feature Group Features Extracted
Speed mean, max, std, range
Heart Rate mean, max, std, range
Altitude mean, max, std, range
Workout Meta duration, n_points, gender

Total: 15 features extracted from time-series arrays


🧹 Data Challenges Solved

  • JSONL with single quotes → used ast.literal_eval instead of json.loads
  • Pre-normalized version → switched to raw endomondoHR.json for real signal
  • Silent NaN bug[~np.isnan(a)] vs a[~np.isnan(a)] — one character, complete feature corruption
  • Class imbalance (run=52%, walk=2%) → SMOTE oversampling on training set only
  • bike vs bike (transport) → merged as physically indistinguishable from sensor data

🤖 Models Trained & Results

Model Accuracy F1 (weighted)
Logistic Regression 0.6911 0.6598
K-Nearest Neighbors 0.7808 0.7769
SVM (RBF kernel) 0.7611 0.7447
Random Forest ✅ 0.8641 0.8585

💡 Key Insights

1. HR beats Speed as top predictor
hr_mean (0.159) outranked speed_mean (0.054).
A slow cyclist and fast runner have identical speeds — but very different heart rates.

2. Duration is almost as important as HR
Cyclists ride longer than runners on average. Duration encodes sport modality implicitly.

3. Mountain bike is the hardest class (41% recall)
MTB overlaps with both bike (cycling motion) and run (slow uphill speed).
Would require cadence or power meter data to fully separate.

4. Model mistakes are physically interpretable
Every misclassification pair makes real-world sense:
bike↔run (speed overlap), mtb→bike (both cycling), walk→run (slow jog overlap).


🛠️ Tech Stack

  • Python, NumPy, Pandas
  • Scikit-learn (RF, SVM, KNN, Logistic Regression)
  • imbalanced-learn (SMOTE)
  • Matplotlib, Seaborn
  • Kaggle Notebooks

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages