Skip to content

Examines strava history and makes upcoming working recommendations to achieve a polarized workout balance

Notifications You must be signed in to change notification settings

ebowman/polarized-training-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸƒβ€β™‚οΈ Polarized Training Analysis Tool

Are you training too hard in the middle zones? This science-backed tool analyzes your Strava data to optimize your training for maximum performance gains.

Polarized Training Dashboard Strava Integration AI Powered

πŸ€” What Problem Does This Solve?

Most endurance athletes make the same critical mistake: they train too much in the "moderate" intensity zone β€” not easy enough to build aerobic base, not hard enough to drive adaptation. This leads to:

  • πŸ’” Chronic fatigue without performance gains
  • πŸ”„ Plateau effects where training stops improving fitness
  • πŸ”₯ Burnout from constantly being "sort of tired"
  • πŸ“‰ Inefficient use of training time

πŸ§ͺ The Science-Based Solution

Research from the National Institutes of Health (NIH) shows that elite endurance athletes follow a "polarized" training distribution:

  • 🟒 80% Low Intensity (Zone 1) - Build massive aerobic base
  • 🟑 10% Threshold (Zone 2) - Lactate threshold work
  • πŸ”΄ 10% High Intensity (Zone 3) - VO2 max and neuromuscular power

This isn't just theory β€” it's how Olympic champions and Tour de France winners actually train.

πŸ“š Research Foundation

Based on the landmark NIH study: "Training Intensity Distribution in Endurance Athletes: Are We Asking the Right Questions?" by Laursen & Buchheit (2019), which analyzed training patterns across:

  • πŸƒβ€β™‚οΈ Marathon runners
  • πŸš΄β€β™€οΈ Professional cyclists
  • πŸŠβ€β™‚οΈ Elite swimmers
  • ⛷️ Cross-country skiers

Key Finding: Athletes who followed the 80/10/10 polarized distribution consistently outperformed those who trained more in moderate zones.

✨ What This Tool Does

πŸ” Analyzes Your Training Reality

  • Connects to your Strava account with one click
  • Downloads your workout data automatically
  • Shows you exactly where your training time is actually going
  • Compares your distribution to the research-proven 80/10/10 target

πŸ“Š Beautiful Web Dashboard

  • Interactive charts for every workout
  • Combined analysis showing trends over time
  • Time range filtering (7 days to all time)
  • Adherence scoring (0-100) to track improvement

πŸ€– AI-Powered Workout Recommendations

  • Uses OpenAI's advanced GPT-4o model
  • Generates personalized workouts based on your data
  • Considers your equipment (Peloton, rowing machine, etc.)
  • Provides detailed workout structure and scientific reasoning

πŸ“₯ Smart Data Management

  • OAuth2 integration for secure Strava connection
  • Intelligent caching (only downloads new workouts)
  • Background processing (no waiting for slow AI responses)
  • NEW: Real-time download progress with activity-by-activity updates
  • NEW: Automatic startup sync (downloads last 30 days if needed)
  • NEW: Graceful rate limit handling with visual countdown

πŸš€ Who Is This For?

βœ… Perfect If You:

  • Train 3+ hours per week consistently
  • Use Strava to track workouts with heart rate or power data
  • Want to optimize your training based on actual science
  • Are curious about how elite athletes really train
  • Feel like you're working hard but not seeing results

❌ Not Right If You:

  • Only do casual, recreational exercise
  • Don't track workouts digitally
  • Are happy with your current training and results
  • Don't have heart rate or power data

πŸ› οΈ How to Get Started

Step 1: Prerequisites

  • Strava account with workout data (heart rate or power zones)
  • Python 3.8+ installed on your computer
  • OpenAI API key (optional, for AI recommendations - $5-10/month)

Step 2: Quick Setup

# Clone the project
git clone https://github.com/your-username/polarized-training-analysis.git
cd polarized-training-analysis

# Install dependencies
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

# Configure your settings
cp .env.example .env
# Edit .env with your details (see below)

Step 3: Configuration

Edit .env file with your information:

# Get these from https://www.strava.com/settings/api
STRAVA_CLIENT_ID=your_client_id_here
STRAVA_CLIENT_SECRET=your_client_secret_here

# Your training zones (find in Strava settings)
MAX_HEART_RATE=180
FTP=250

# FTP Test Data (optional - for LTHR-based HR zones)
# Fill these from your most recent 20-minute FTP test
AVERAGE_FTP_HR=0  # Average HR during FTP test (this is your LTHR)
MAX_FTP_HR=0      # Max HR during FTP test
AVERAGE_FTP_POWER=0  # Average power during 20-min test

# Optional: Get from https://platform.openai.com/api-keys
OPENAI_API_KEY=your_openai_api_key_here

# Security (generate any random string)
FLASK_SECRET_KEY=your_secret_key_here

Step 4: Launch & Connect

# Start the web dashboard
python web_server.py

# Optional: Disable automatic download on startup
python web_server.py --no-auto-download

# Open browser to http://localhost:5000
# The app will automatically check for data and start downloading if needed
# Or click "πŸ“₯ Download Latest" to manually sync with Strava

🎯 What You'll See

Live Download Progress

  • Real-time progress bar showing download percentage
  • Current activity name being downloaded
  • Animated list of new activities as they're downloaded
  • Rate limit countdown when Strava API limits are hit
  • Automatic retry with graceful error handling

Immediate Insights

  • Your actual training distribution (e.g., "65% Zone 1, 25% Zone 2, 10% Zone 3")
  • Adherence score showing how close you are to optimal
  • Individual workout breakdowns with zone percentages

Actionable Recommendations

  • "🚨 High Priority: Add 90min Zone 1 ride" - You're only getting 60% Zone 1 (need 80%)
  • "⚠️ Medium Priority: 45min Zone 3 intervals" - Haven't done high intensity in 8 days
  • "πŸ’‘ Low Priority: Recovery ride" - Optional active recovery

AI-Powered Coaching

  • Equipment-specific workouts: "Power Zone 2 endurance ride on Peloton (90 min)"
  • Scientific reasoning: "Your Zone 1 percentage is 15% below target, limiting aerobic adaptation"
  • Progressive structure: Detailed warmup, intervals, and cooldown instructions

🎯 Personalizing AI Recommendations

Two-Tier Preference System

The tool supports both default and personal preferences for maximum flexibility:

  • πŸ“‹ Default preferences (workout_preferences.md) - Baseline recommendations included with the project
  • ✏️ Personal preferences (workout_preferences_personal.md) - Your custom goals and constraints (not tracked by git)

How to Customize

  1. Copy the example: cp workout_preferences_personal.md.example workout_preferences_personal.md
  2. Edit your personal file with your specific goals, equipment, time constraints, and training preferences
  3. The AI automatically uses your personal file if it exists, otherwise falls back to the default

What You Can Customize

  • Training goals (marathon times, FTP targets, race preparation)
  • Available equipment (Peloton models, rowing machines, weights)
  • Time constraints (weekday limits, weekend availability)
  • Workout preferences (interval vs steady-state, morning vs evening)
  • Physical considerations (injury history, recovery needs)
  • Seasonal periodization (base building, peak, recovery phases)

Benefits

  • πŸ”’ Privacy: Personal goals stay on your computer, not in git
  • πŸ”„ Updates: Pull project updates without losing customizations
  • πŸ‘₯ Sharing: Share the project while keeping personal details private
  • 🎯 Precision: AI gets highly specific recommendations based on your actual situation

πŸ’‘ Real-World Example

Sarah's Story: Marathon runner, 35, training 6 hours/week

Before: 50% Zone 1, 40% Zone 2, 10% Zone 3 β†’ Constantly tired, plateau at 3:45 marathon

After Analysis: Tool showed she was doing too much "junk miles" in Zone 2

New Plan: 80% Zone 1, 10% Zone 2, 10% Zone 3 β†’ Broke through to 3:32 marathon, felt more energized

πŸ”¬ The Science Deep Dive

Why 80/10/10 Works

  1. 🟒 Zone 1 (80%): Builds mitochondrial density, capillarization, fat oxidation
  2. 🟑 Zone 2 (10%): Improves lactate clearance and metabolic efficiency
  3. πŸ”΄ Zone 3 (10%): Drives VO2 max and neuromuscular adaptations

Why "Moderate" Training Fails

  • Zone 2 overload creates chronic stress without full recovery
  • Prevents adaptation to both aerobic and anaerobic systems
  • "Black hole of training" - too hard to recover from, not hard enough to adapt

Elite Athlete Data

  • Tour de France riders: 80.2% Zone 1, 9.1% Zone 2, 10.7% Zone 3
  • Olympic marathoners: 77.8% Zone 1, 12.1% Zone 2, 10.1% Zone 3
  • World-class cyclists: Consistently maintain >75% Zone 1 across all training phases

πŸ›‘οΈ Privacy & Security

  • Local data processing: Your workout data stays on your computer
  • Secure OAuth: Industry-standard Strava authentication
  • No data selling: This is a personal training tool, not a data collection service
  • Open source: You can see exactly what the code does

🀝 Contributing & Support

Found a Bug?

  • Open an issue on GitHub with details
  • Include your training data setup (anonymized)

Want to Contribute?

  • Fork the repository
  • Add features or fix bugs
  • Submit a pull request

Need Help?

  • Check the troubleshooting section below
  • Review your .env configuration
  • Ensure Strava has heart rate/power data

πŸ”§ Troubleshooting

"No activities found"

  • βœ… Check Strava authorization: Click "πŸ“₯ Download Latest"
  • βœ… Ensure activities have heart rate or power data
  • βœ… Try longer time range (30+ days)

"AI recommendations not loading"

  • βœ… Check OPENAI_API_KEY in .env file
  • βœ… Verify OpenAI account has API access
  • βœ… Look for error messages in browser console

"Port already in use"

  • βœ… Use different port: python web_server.py --port 5001
  • βœ… Or kill existing processes: ./kill_server.sh

"Import errors"

  • βœ… Activate virtual environment: source venv/bin/activate
  • βœ… Install dependencies: pip install -r requirements.txt

πŸ“ˆ Advanced Features

Multi-Sport Analysis

  • πŸš΄β€β™€οΈ Cycling: Power zone analysis (FTP-based)
  • πŸš£β€β™‚οΈ Rowing: Heart rate zone analysis
  • πŸƒβ€β™‚οΈ Running: Heart rate zone analysis
  • πŸ‹οΈβ€β™€οΈ Strength: RPE-based recommendations

Time Window Intelligence

  • Display analysis: User-selected time range for historical trends
  • AI recommendations: Always based on last 14 days for relevance
  • Dual-window approach: Balances long-term trends with immediate needs

Advanced Zone Systems

The app supports both simplified and advanced zone models:

Heart Rate Zones

  • LTHR-based (7-zone): When you have FTP test data
    • Z1 Recovery: <81% LTHR
    • Z2 Aerobic: 81-89% LTHR
    • Z3 Tempo: 90-93% LTHR
    • Z4 Threshold: 94-99% LTHR
    • Z5 VO2max/Anaerobic: 100-106% LTHR
  • Max HR-based (3-zone): Simplified fallback model
    • Zone 1: ≀82% Max HR (aerobic base)
    • Zone 2: 82-87% Max HR (threshold)
    • Zone 3: >87% Max HR (high intensity)

Power Zones (Cycling)

  • 7-zone Coggan model based on FTP
  • Automatically used for cycling activities
  • Falls back to HR if no power data

Sport-Specific Analysis

  • Cycling: Power zones preferred, HR fallback
  • Running/Rowing: Heart rate zones only
  • Strength Training: Excluded from zone analysis

API Endpoints

GET /                              # Web dashboard
GET /download-workouts             # OAuth2 Strava connection
POST /api/download-workouts        # Download latest activities
GET /api/ai-status/<session_id>    # Check AI generation status
POST /api/ai-recommendations/refresh # Generate new AI recommendations

πŸŽ‰ Success Stories

"This tool completely changed how I think about training. I was doing way too much Zone 2 'tempo' work. After switching to proper polarized training, I PR'd in my next race and felt more energized than ever." β€” Mike R., Cyclist

"The AI recommendations are incredibly smart. It suggested specific Peloton classes that perfectly matched what my training analysis showed I needed. Game changer!" β€” Jennifer K., Triathlete

"As a coach, this gives me objective data to show athletes why their training isn't working. The NIH research backing makes it credible with skeptical athletes." β€” Coach David L.

πŸ“š Further Reading

πŸ“„ License

MIT License - Feel free to use, modify, and share!


πŸš€ Ready to Transform Your Training?

The difference between good and great athletes isn't just talent β€” it's training smarter, not just harder.

Start your polarized training journey today:

git clone https://github.com/your-username/polarized-training-analysis.git
cd polarized-training-analysis
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Edit .env with your settings
python web_server.py

Train like the elites. See results like the elites. πŸ†


Built with ❀️ for the endurance community. Based on peer-reviewed research. Powered by your data.

About

Examines strava history and makes upcoming working recommendations to achieve a polarized workout balance

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •