Exercises: Defensive Metrics and Analysis
Level 1: Conceptual Understanding
Exercise 1.1: Tackle Limitations
Explain why a linebacker with 120 tackles might be less valuable than one with 80 tackles. What additional metrics would you need to properly compare them?
Exercise 1.2: EPA Allowed Interpretation
If a defense has an EPA allowed of -0.08 per play, what does this mean? Is this good or bad? How does it compare to league average?
Exercise 1.3: Pressure vs. Sacks
Why is pressure rate considered a more stable metric than sack rate for evaluating pass rushers? What does this tell us about sack totals?
Exercise 1.4: Coverage Evaluation
A cornerback has allowed only 35 catches on 65 targets (53.8% completion rate). However, opponents rarely throw at him. What additional context do you need to properly evaluate this player?
Exercise 1.5: Opponent Adjustment
Team A allows 350 yards per game against an easy schedule. Team B allows 380 yards per game against the toughest schedule in the country. Which defense is likely better? How would you quantify the difference?
Level 2: Basic Calculations
Exercise 2.1: Defensive Success Rate
Calculate the defensive success rate (stop rate) from these plays:
| Play | Down | Distance | Yards Allowed |
|---|---|---|---|
| 1 | 1 | 10 | 3 |
| 2 | 2 | 7 | 5 |
| 3 | 3 | 2 | 4 |
| 4 | 1 | 10 | 6 |
| 5 | 2 | 4 | 1 |
| 6 | 3 | 3 | 2 |
| 7 | 1 | 10 | 12 |
| 8 | 2 | 8 | 2 |
| 9 | 3 | 6 | 4 |
| 10 | 4 | 2 | 3 |
Success thresholds: 1st = 40%, 2nd = 50%, 3rd/4th = 100%
Exercise 2.2: Pressure Rate Calculation
A defense faced 450 dropbacks this season: - Generated 126 pressures - Recorded 32 sacks - Had 58 hurries - Had 36 QB hits
Calculate: pressure rate, sack rate, hurry rate, and sack conversion rate (sacks/pressures).
Exercise 2.3: Passer Rating Allowed
A cornerback was targeted 70 times and allowed: - 38 completions - 425 yards - 3 touchdowns - 2 interceptions
Calculate the passer rating allowed using the NFL formula.
Exercise 2.4: Stuff Rate
From these rushing plays, calculate the stuff rate (plays ≤ 0 yards):
Yards allowed: [4, -1, 2, 0, 6, -2, 3, 0, 5, 1, -1, 4, 2, 8, 0, 3, -1, 2, 5, 1]
Also calculate TFL rate (plays < 0 yards).
Exercise 2.5: Run Defense Metrics
A defense faced 380 rushing attempts and allowed: - 1,520 total yards - 680 yards before contact - 72 stuffs (≤ 0 yards) - 38 explosive runs (10+ yards)
Calculate: YPC allowed, avg YBC allowed, stuff rate, and explosive run rate.
Level 3: Implementation
Exercise 3.1: Defensive EPA Calculator
def calculate_defensive_epa(plays: List[Dict]) -> Dict:
"""
Calculate EPA allowed by defense.
Parameters:
-----------
plays : list
Each play has: yard_line_before, yard_line_after, down_before,
down_after, distance_before, distance_after,
turnover (bool), touchdown (bool)
Returns:
--------
dict with:
- total_epa_allowed
- epa_per_play
- positive_play_rate (plays with negative EPA = good for defense)
"""
pass
Exercise 3.2: Pass Rush Analyzer
def analyze_pass_rush(dropbacks: List[Dict]) -> Dict:
"""
Analyze pass rush effectiveness.
Parameters:
-----------
dropbacks : list
Each dropback has: pressure (bool), sack (bool),
hurry (bool), hit (bool), blitz (bool)
Returns:
--------
dict with:
- pressure_rate
- sack_rate
- sack_conversion_rate
- blitz_analysis (rates when blitzing vs not)
"""
pass
Exercise 3.3: Coverage Evaluator
def evaluate_coverage(targets: List[Dict]) -> Dict:
"""
Evaluate defender coverage performance.
Parameters:
-----------
targets : list
Each target has: completion (bool), yards, touchdown (bool),
interception (bool), pass_breakup (bool)
Returns:
--------
dict with:
- completion_rate_allowed
- yards_per_target
- passer_rating_allowed
- coverage_score (0-100)
"""
pass
Exercise 3.4: Run Defense Analyzer
def analyze_run_defense(rushes: List[Dict]) -> Dict:
"""
Analyze run defense performance.
Parameters:
-----------
rushes : list
Each rush has: yards_gained, yards_before_contact,
gap, down, distance
Returns:
--------
dict with:
- ypc_allowed
- avg_ybc_allowed
- stuff_rate
- success_rate_allowed
- by_gap analysis
"""
pass
Exercise 3.5: Opponent Adjuster
def adjust_for_opponents(raw_stats: Dict,
opponents: List[Dict],
league_avg: Dict) -> Dict:
"""
Adjust defensive statistics for opponent quality.
Parameters:
-----------
raw_stats : dict
Raw defensive statistics
opponents : list
Opponent offensive statistics faced
league_avg : dict
League average offensive statistics
Returns:
--------
dict with:
- raw_stats
- adjustment_factor
- adjusted_stats
"""
pass
Level 4: Advanced Analysis
Exercise 4.1: Comprehensive Defensive Grader
class DefensiveGrader:
"""
Grade defense across all components.
Components:
- Pass defense (coverage + pass rush)
- Run defense
- Situational (3rd down, red zone)
- Turnovers
"""
def __init__(self):
pass
def grade_pass_defense(self, data: Dict) -> Dict:
"""Grade pass defense component."""
pass
def grade_run_defense(self, data: Dict) -> Dict:
"""Grade run defense component."""
pass
def grade_situational(self, data: Dict) -> Dict:
"""Grade situational defense."""
pass
def grade_turnovers(self, data: Dict) -> Dict:
"""Grade turnover generation."""
pass
def generate_overall_grade(self, data: Dict) -> Dict:
"""Generate composite grade with breakdown."""
pass
Exercise 4.2: Position Evaluator
class PositionEvaluator:
"""
Position-specific defensive player evaluation.
"""
def evaluate_edge_rusher(self, stats: Dict) -> Dict:
"""
Evaluate edge rusher.
Key metrics: PRWR, pressure rate, run defense
"""
pass
def evaluate_cornerback(self, stats: Dict) -> Dict:
"""
Evaluate cornerback.
Key metrics: Coverage grade, passer rating allowed, playmaking
"""
pass
def evaluate_linebacker(self, stats: Dict) -> Dict:
"""
Evaluate linebacker.
Key metrics: Run stop rate, coverage grade, tackling
"""
pass
def evaluate_safety(self, stats: Dict) -> Dict:
"""
Evaluate safety.
Key metrics: Coverage, run support, range, turnovers
"""
pass
Exercise 4.3: Scheme Analyzer
class DefensiveSchemeAnalyzer:
"""
Analyze defensive scheme effectiveness.
"""
def analyze_coverage_scheme(self, plays: List[Dict]) -> Dict:
"""
Compare man vs zone coverage performance.
"""
pass
def analyze_blitz_patterns(self, plays: List[Dict]) -> Dict:
"""
Analyze blitz frequency and effectiveness by situation.
"""
pass
def analyze_fronts(self, plays: List[Dict]) -> Dict:
"""
Compare 3-4 vs 4-3 front performance.
"""
pass
def recommend_adjustments(self, analysis: Dict) -> List[str]:
"""
Generate scheme recommendations based on analysis.
"""
pass
Exercise 4.4: Defensive Player Comparison
def compare_defenders(players: Dict[str, Dict]) -> pd.DataFrame:
"""
Compare multiple defensive players.
Parameters:
-----------
players : dict
Maps player name to their statistics
Returns:
--------
DataFrame with standardized metrics and rankings
"""
pass
Exercise 4.5: Defensive Consistency Analyzer
class DefensiveConsistencyAnalyzer:
"""
Analyze defensive performance consistency.
"""
def calculate_weekly_variance(self, weekly_stats: List[Dict]) -> Dict:
"""
Calculate variance in key metrics week-to-week.
"""
pass
def identify_bad_games(self, weekly_stats: List[Dict]) -> List[Dict]:
"""
Identify games where defense performed poorly.
"""
pass
def analyze_garbage_time_impact(self, plays: List[Dict]) -> Dict:
"""
Separate garbage time stats from competitive plays.
"""
pass
Level 5: Research Projects
Exercise 5.1: Pressure Rate Stability Study
Research question: How stable is pressure rate year-over-year for pass rushers?
Tasks: 1. Collect multi-year pressure data for 50+ pass rushers 2. Calculate year-over-year correlation 3. Compare stability to sack rate 4. Determine minimum sample size for reliable evaluation 5. Present findings with visualizations
Exercise 5.2: Coverage Metric Predictive Value
Study: Which coverage metric best predicts future performance?
Tasks: 1. Analyze completion rate allowed, passer rating allowed, EPA/target 2. Compare predictive power year-over-year 3. Control for target quality 4. Identify which metrics are skill vs. luck 5. Recommend optimal evaluation approach
Exercise 5.3: Blitz Effectiveness Analysis
Analyze when blitzing is optimal and when it's counterproductive.
Tasks: 1. Collect blitz data across multiple teams/seasons 2. Compare outcomes (EPA) when blitzing vs. not 3. Identify situational factors (down, distance, score) 4. Analyze which teams blitz effectively 5. Build predictive model for blitz success
Exercise 5.4: Run Defense Attribution
Study: How much of run defense success is due to the front seven vs. scheme?
Tasks: 1. Analyze yards before contact by team and scheme 2. Study effect of personnel groupings 3. Control for opponent rushing ability 4. Separate DL, LB, and secondary contributions 5. Quantify scheme vs. talent impact
Exercise 5.5: Defensive Consistency and Winning
Research: Does defensive consistency matter more than average performance?
Tasks: 1. Define defensive consistency metrics 2. Analyze relationship between consistency and wins 3. Compare to average performance relationship 4. Identify what makes defenses consistent 5. Recommend roster construction strategies
Bonus Challenges
Challenge A: Real-Time Defensive Dashboard
Build an interactive dashboard showing: - Rolling defensive EPA - Coverage heat map - Pass rush performance trends - Situational success rates - Player grades
Challenge B: Defensive Play Prediction
Build a model to predict defensive play calls: - Features: Down, distance, formation, score, time - Target: Coverage type, blitz likelihood - Evaluate with AUC - Identify predictable vs. unpredictable defenses
Challenge C: Defensive Player Value Model
Create a comprehensive player value model: - Combine all position-specific metrics - Weight by position importance - Calculate replacement level - Assign dollar values - Compare to actual contracts
Solutions
Solutions are available in code/exercise-solutions.py