/NHL-Odds

Primary LanguagePython

NHL-Odds Calculator

In an attempt to make quick money against friends, we created this computer program that analyzes current season trends and uses math/statistics to predict scores and win percentages.

Quick Start

Install Dependencies

pip install -r requirements.txt

Run the program

python main.py

Poisson Distribution and Win Percentage Calculation

We created a Poisson Distribution in the python code using SciPy

Heatmapping the values from each poisson calculation would give us a graph similar to this: Screen Shot 2022-08-17 at 1 29 25 AM Using all the data from the distribution, we are able to find the win percentage by summing the percentages of the situations where one team scores higher than another. Afterwards we calculate tie percentages using the same method.

Visual of cells that would be added together in order to find a win percentage. Screen Shot 2022-08-17 at 1 38 23 AM

Score Prediction

    def calculate_score(self):
        t1=leagueGF*(self.home['Attack Strength']*self.away["Defense Strength"])
        t2=leagueGF*(self.away['Attack Strength']*self.home["Defense Strength"])
        return(t1,t2) #home, away
        

$$ Score = League Average GF * {Attack Strength*Defense Strength} $$


Attack Strength / Defensive Strength Calculation

    for i in teamsData:
        teamsData[i]['Attack Strength']=(teamsData[i]['GF']/teamsData[i]['Games Played'])/leagueGF
        teamsData[i]['Defense Strength']=(teamsData[i]['GA']/teamsData[i]['Games Played'])/leagueGA
    return teamsData
    

$$ Attack Strength = {Average Goals Count\over League Average GF}$$

$$ Defensive Strength = {Average Goals Against Count\over League Average GA} $$