penaltyblog.models.PoissonGoalsModel#
- class penaltyblog.models.PoissonGoalsModel(goals_home: Sequence[int] | ndarray[Any, dtype[int64]] | Series, goals_away: Sequence[int] | ndarray[Any, dtype[int64]] | Series, teams_home: Sequence[str] | ndarray[Any, dtype[str_]] | Series, teams_away: Sequence[str] | ndarray[Any, dtype[str_]] | Series, weights: float | Sequence[float] | ndarray[Any, dtype[float64]] | Series | None = None)[source]#
Bases:
BaseGoalsModel
Poisson model for predicting outcomes of football (soccer) matches
- fit()[source]#
fits a Poisson model to the data to calculate the team strengths. Must be called before the model can be used to predict game outcomes
- predict(home_team, away_team, max_goals=15)[source]#
predict the outcome of a football (soccer) game between the home_team and away_team
- __init__(goals_home: Sequence[int] | ndarray[Any, dtype[int64]] | Series, goals_away: Sequence[int] | ndarray[Any, dtype[int64]] | Series, teams_home: Sequence[str] | ndarray[Any, dtype[str_]] | Series, teams_away: Sequence[str] | ndarray[Any, dtype[str_]] | Series, weights: float | Sequence[float] | ndarray[Any, dtype[float64]] | Series | None = None)[source]#
Dixon and Coles adjusted Poisson model for predicting outcomes of football (soccer) matches
- Parameters:
goals_home (array_like) – The number of goals scored by the home team in each match
goals_away (array_like) – The number of goals scored by the away team in each match
teams_home (array_like) – The name of the home team in each match
teams_away (array_like) – The name of the away team in each match
weights (array_like, optional) – The weight of each match, by default None
Methods
__init__
(goals_home, goals_away, teams_home, ...)Dixon and Coles adjusted Poisson model for predicting outcomes of football (soccer) matches
fit
()Fits the model to the data.
Returns the fitted parameters of the model.
load
(filepath)Loads a model from a file.
predict
(home_team, away_team[, max_goals])Predicts the probability of each scoreline for a given home and away team
save
(filepath)Saves the model to a file using pickle.
Attributes
Property to retrieve the fitted model parameters.
- classmethod load(filepath: str) Any #
Loads a model from a file.
- Parameters:
filepath (str) – The path to the file from which the model will be loaded.
- Returns:
An instance of the model.
- Return type:
Any
- property params: Dict[str, Any]#
Property to retrieve the fitted model parameters. Same as get_params(), but allows attribute-like access.
- Returns:
A dictionary containing attack, defense, home advantage, and correlation parameters.
- Return type:
dict
- Raises:
ValueError – If the model has not been fitted yet.
- predict(home_team: str, away_team: str, max_goals: int = 15) FootballProbabilityGrid [source]#
Predicts the probability of each scoreline for a given home and away team
- Parameters:
home_team (str) – The name of the home team
away_team (str) – The name of the away team
max_goals (int, optional) – The maximum number of goals to consider, by default 15
- Returns:
A FootballProbabilityGrid object containing the probabilities of each scoreline
- Return type:
- save(filepath: str)#
Saves the model to a file using pickle.
- Parameters:
filepath (str) – The path to the file where the model will be saved.