highlyprofitable108 / top-secret-modeling

full-monte-football-sim
0 stars 0 forks source link

New O and D Line Rankings #66

Closed highlyprofitable108 closed 1 year ago

highlyprofitable108 commented 1 year ago

Defensive Line Rating

For the defensive line, you want to capture their ability to disrupt the offense. Key stats could include:

You could create a rating by normalizing each of these statistics (e.g., converting them to a scale of 0 to 100) and then taking a weighted average based on their perceived importance.

Offensive Line Rating

For the offensive line, the focus is on protection and run blocking. Key stats could include:

Again, you would normalize these stats and then take a weighted average. It's important to consider that some stats may be inversely related to line performance (like sacks allowed), so they would need to be inverted (e.g., a lower number of sacks allowed would contribute to a higher rating).

Here's a simple example of how you might calculate these ratings:

def calculate_defensive_line_rating(sacks, tloss, qb_hits, hurries, forced_fumbles, knockdowns):
    # Normalize each stat to a 0-100 scale based on league max/min for the season
    # Then take a weighted average
    # Weights are hypothetical and should be determined by analysis
    weights = {'sacks': 0.25, 'tloss': 0.2, 'qb_hits': 0.2, 'hurries': 0.15, 'forced_fumbles': 0.1, 'knockdowns': 0.1}
    stats = {'sacks': sacks, 'tloss': tloss, 'qb_hits': qb_hits, 'hurries': hurries, 'forced_fumbles': forced_fumbles, 'knockdowns': knockdowns}

    rating = sum(weights[stat] * normalize(stats[stat]) for stat in stats)
    return rating

def calculate_offensive_line_rating(pocket_time, sacks_allowed, hurries_allowed, knockdowns_allowed, rushing_yards_before_contact, yac):
    # Normalize and invert where necessary (e.g., fewer sacks allowed is better)
    # Weights are hypothetical and should be determined by analysis
    weights = {'pocket_time': 0.2, 'sacks_allowed': 0.25, 'hurries_allowed': 0.25, 'knockdowns_allowed': 0.15, 'rushing_yards_before_contact': 0.1, 'yac': 0.05}
    stats = {'pocket_time': pocket_time, 'sacks_allowed': sacks_allowed, 'hurries_allowed': hurries_allowed, 'knockdowns_allowed': knockdowns_allowed, 'rushing_yards_before_contact': rushing_yards_before_contact, 'yac': yac}

    rating = sum(weights[stat] * (100 - normalize(stats[stat])) if stat in ['sacks_allowed', 'hurries_allowed', 'knockdowns_allowed'] else weights[stat] * normalize(stats[stat]) for stat in stats)
    return rating

def normalize(value, min_value=0, max_value=100):
    # Placeholder normalization function, should be replaced with actual normalization logic
    return (value - min_value) / (max_value - min_value) * 100

In this example, normalize is a placeholder function that you would need to replace with actual logic based on the range of values for each statistic. The weights are also hypothetical and should be determined based

highlyprofitable108 commented 1 year ago

Implemented advanced.offensive and .defensize line metrics in dev and added to mongo. Testing...