Football-Data soccer data

This example illustrates the usage of Football-Data soccer dataloader.

# Author: Georgios Douzas <gdouzas@icloud.com>
# Licence: MIT

import pandas as pd
from sportsbet.datasets import FDSoccerDataLoader

Getting the available parameters

We can get the available parameters in order to select the training data to be extracted, using the get_all_params() class method.

The available parameters can be presented as a DataFrame.

params_df = pd.DataFrame(params).sort_values(
    ['league', 'year', 'division'], ignore_index=True
)
params_df
division league year
0 1 Argentina 2013
1 1 Argentina 2014
2 1 Argentina 2015
3 1 Argentina 2016
4 1 Argentina 2017
... ... ... ...
753 1 USA 2018
754 1 USA 2019
755 1 USA 2020
756 1 USA 2021
757 1 USA 2022

758 rows × 3 columns



We select to extract training data only for the year 2021 of the first division Spanish and Italian leagues.

param_grid = {'league': ['Spain', 'Italy'], 'division': [1], 'year': [2021]}

Getting the available odds types

We can get the available odds types in order to match the output of the training data, using the get_odds_types() class method.

Out:

['bet365', 'bet365_closing', 'betbrain', 'betbrain_average', 'betbrain_maximum', 'betwin', 'betwin_closing', 'bluesquare', 'gamebookers', 'interwetten', 'interwetten_closing', 'ladbrokes', 'market_average', 'market_average_closing', 'market_maximum', 'market_maximum_closing', 'pinnacle', 'pinnacle_closing', 'sporting', 'sportingbet', 'stanjames', 'stanleybet', 'vcbet', 'vcbet_closing', 'williamhill', 'williamhill_closing']

We select the odds types to be the market average.

odds_type = 'market_average'

Extracting the training data

We extract the training data, keeping columns and rows with non missing values by setting the drop_na_thres parameter equal to 1.0.

Out:

Football-Data.co.uk: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00

The input data:

home_team away_team market_maximum__home_win__odds market_maximum__draw__odds market_maximum__away_win__odds market_average__home_win__odds market_average__draw__odds market_average__away_win__odds bet365_closing__home_win__odds bet365_closing__draw__odds bet365_closing__away_win__odds betwin_closing__home_win__odds betwin_closing__draw__odds betwin_closing__away_win__odds interwetten_closing__home_win__odds interwetten_closing__draw__odds interwetten_closing__away_win__odds pinnacle_closing__home_win__odds pinnacle_closing__draw__odds pinnacle_closing__away_win__odds williamhill_closing__home_win__odds williamhill_closing__draw__odds williamhill_closing__away_win__odds vcbet_closing__home_win__odds vcbet_closing__draw__odds vcbet_closing__away_win__odds market_maximum_closing__home_win__odds market_maximum_closing__draw__odds market_maximum_closing__away_win__odds market_average_closing__home_win__odds market_average_closing__draw__odds market_average_closing__away_win__odds market_maximum_closing__over_2.5__odds market_maximum_closing__under_2.5__odds market_average_closing__over_2.5__odds market_average_closing__under_2.5__odds market_average_closing__size_of_asian_handicap_home_team__odds bet365_closing__asian_handicap_home_team__odds bet365_closing__asian_handicap_away_team__odds pinnacle_closing__asian_handicap_home_team__odds pinnacle_closing__asian_handicap_away_team__odds market_maximum_closing__asian_handicap_home_team__odds market_maximum_closing__asian_handicap_away_team__odds market_average_closing__asian_handicap_home_team__odds market_average_closing__asian_handicap_away_team__odds league division year
date
2020-09-12 Eibar Celta 2.66 3.27 3.13 2.53 3.16 2.97 2.62 3.10 2.80 2.75 3.00 2.80 2.75 2.80 2.80 2.87 3.07 2.87 2.75 3.0 2.80 2.70 3.10 2.75 2.87 3.20 3.00 2.75 3.01 2.83 2.74 1.57 2.54 1.51 0.00 1.94 1.96 1.96 1.96 1.98 2.01 1.92 1.96 Spain 1 2021
2020-09-12 Granada Ath Bilbao 2.92 3.22 2.89 2.82 3.00 2.75 2.50 2.90 3.20 2.75 2.80 3.00 2.70 2.55 3.10 2.67 2.91 3.30 2.55 2.9 3.20 2.55 2.90 3.13 2.85 3.08 3.38 2.65 2.86 3.12 3.20 1.45 2.99 1.38 0.00 1.74 2.19 1.77 2.20 1.93 2.23 1.78 2.11 Spain 1 2021
2020-09-12 Cadiz Osasuna 2.93 3.08 2.97 2.80 2.95 2.82 3.20 2.90 2.50 3.00 2.80 2.75 3.15 2.55 2.70 3.41 2.90 2.61 3.20 2.8 2.60 3.20 2.80 2.60 3.42 2.97 2.76 3.21 2.81 2.63 3.32 1.43 3.08 1.36 0.25 1.72 2.07 1.79 2.17 1.81 2.25 1.74 2.17 Spain 1 2021
2020-09-13 Alaves Betis 2.99 3.35 2.76 2.83 3.21 2.59 3.30 3.10 2.35 3.40 3.20 2.25 3.30 2.80 2.40 3.57 3.13 2.37 3.40 3.1 2.30 3.25 3.20 2.30 3.57 3.30 2.47 3.35 3.10 2.35 2.49 1.69 2.33 1.61 0.25 1.93 1.97 1.93 2.00 1.95 2.05 1.88 1.99 Spain 1 2021
2020-09-13 Valladolid Sociedad 3.04 3.38 2.65 2.88 3.20 2.55 3.00 3.00 2.55 3.00 3.00 2.60 3.05 2.60 2.75 3.19 2.92 2.74 3.00 3.0 2.62 2.90 2.90 2.70 3.24 3.13 2.80 3.04 2.88 2.69 3.20 1.45 2.90 1.40 0.00 2.07 1.83 2.13 1.82 2.13 1.88 2.06 1.82 Spain 1 2021
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2021-05-23 Napoli Verona 1.23 8.00 15.35 1.20 7.24 13.39 1.25 6.50 9.50 1.25 6.50 10.50 1.20 7.50 12.00 1.26 6.74 11.05 1.27 6.0 10.00 1.22 6.50 12.00 1.31 7.50 12.00 1.25 6.64 10.43 1.42 3.50 1.35 3.15 -1.75 2.06 1.87 2.03 1.88 2.09 2.01 1.98 1.89 Italy 1 2021
2021-05-23 Bologna Juventus 13.28 7.10 1.28 11.64 6.62 1.24 9.50 5.75 1.28 9.75 6.00 1.28 12.00 6.50 1.22 12.88 6.54 1.25 12.00 6.0 1.25 12.00 7.00 1.22 15.00 7.00 1.30 11.37 6.36 1.25 1.45 3.55 1.36 3.10 1.75 2.02 1.91 2.03 1.88 2.14 1.93 2.00 1.87 Italy 1 2021
2021-05-23 Sevilla Alaves 1.60 4.80 6.60 1.55 4.31 6.01 1.36 5.25 8.00 1.36 5.25 7.75 1.35 5.25 8.50 1.34 5.70 9.69 1.36 5.0 8.50 1.33 5.25 9.00 1.42 5.70 9.69 1.36 5.27 8.48 1.63 2.50 1.57 2.40 -1.50 1.97 1.96 1.93 1.99 2.13 2.03 1.99 1.88 Spain 1 2021
2021-05-23 Torino Benevento 1.87 4.53 4.20 1.80 4.24 3.91 1.60 4.50 5.00 1.62 4.50 4.75 1.65 4.10 4.90 1.67 4.55 4.89 1.60 4.2 5.25 1.60 4.33 5.25 1.70 4.75 5.46 1.63 4.41 4.89 1.53 2.93 1.46 2.68 -1.00 2.02 1.77 2.13 1.80 2.17 1.93 2.06 1.81 Italy 1 2021
2021-05-23 Atalanta Milan 2.53 4.45 2.69 2.45 4.07 2.55 2.25 4.00 2.70 2.30 4.00 2.75 2.40 3.85 2.65 2.41 4.02 2.80 2.38 4.0 2.62 2.38 3.60 2.88 2.45 4.44 2.89 2.34 3.93 2.75 1.53 3.25 1.47 2.66 -0.25 2.09 1.84 2.12 1.83 2.12 1.87 2.07 1.81 Italy 1 2021

760 rows × 48 columns



The targets:

away_win__full_time_goals draw__full_time_goals home_win__full_time_goals over_2.5__full_time_goals under_2.5__full_time_goals
0 False True False False True
1 False False True False True
2 True False False False True
3 True False False False True
4 False True False False True
... ... ... ... ... ...
755 False True False False True
756 True False False True False
757 False False True False True
758 False True False False True
759 True False False False True

760 rows × 5 columns



The market average odds:

market_average__away_win__odds market_average__draw__odds market_average__home_win__odds market_average__over_2.5__odds market_average__under_2.5__odds
0 2.97 3.16 2.53 2.31 1.61
1 2.75 3.00 2.82 2.61 1.49
2 2.82 2.95 2.80 2.70 1.46
3 2.59 3.21 2.83 2.18 1.68
4 2.55 3.20 2.88 2.25 1.65
... ... ... ... ... ...
755 13.39 7.24 1.20 1.31 3.40
756 1.24 6.62 11.64 1.31 3.38
757 6.01 4.31 1.55 1.57 2.39
758 3.91 4.24 1.80 1.52 2.53
759 2.55 4.07 2.45 1.38 2.98

760 rows × 5 columns



Extracting the fixtures data

We extract the fixtures data with columns that match the columns of the training data. On the other hand, the fixtures data are not affected by the param_grid selection.

The input data:

home_team away_team market_maximum__home_win__odds market_maximum__draw__odds market_maximum__away_win__odds market_average__home_win__odds market_average__draw__odds market_average__away_win__odds bet365_closing__home_win__odds bet365_closing__draw__odds bet365_closing__away_win__odds betwin_closing__home_win__odds betwin_closing__draw__odds betwin_closing__away_win__odds interwetten_closing__home_win__odds interwetten_closing__draw__odds interwetten_closing__away_win__odds pinnacle_closing__home_win__odds pinnacle_closing__draw__odds pinnacle_closing__away_win__odds williamhill_closing__home_win__odds williamhill_closing__draw__odds williamhill_closing__away_win__odds vcbet_closing__home_win__odds vcbet_closing__draw__odds vcbet_closing__away_win__odds market_maximum_closing__home_win__odds market_maximum_closing__draw__odds market_maximum_closing__away_win__odds market_average_closing__home_win__odds market_average_closing__draw__odds market_average_closing__away_win__odds market_maximum_closing__over_2.5__odds market_maximum_closing__under_2.5__odds market_average_closing__over_2.5__odds market_average_closing__under_2.5__odds market_average_closing__size_of_asian_handicap_home_team__odds bet365_closing__asian_handicap_home_team__odds bet365_closing__asian_handicap_away_team__odds pinnacle_closing__asian_handicap_home_team__odds pinnacle_closing__asian_handicap_away_team__odds market_maximum_closing__asian_handicap_home_team__odds market_maximum_closing__asian_handicap_away_team__odds market_average_closing__asian_handicap_home_team__odds market_average_closing__asian_handicap_away_team__odds league division year
date
2022-01-26 West Brom Preston 1.66 4.00 6.30 1.62 3.81 5.70 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN England 4 2022
2022-01-26 Quevilly Rouen Amiens 3.14 3.25 2.71 2.92 3.14 2.44 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN France 2 2022
2022-01-26 Dundee United Ross County 2.53 3.35 3.18 2.40 3.20 2.99 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Scotland 4 2022
2022-01-26 Hearts Celtic 5.10 4.00 1.75 4.64 3.81 1.71 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Scotland 4 2022
2022-01-26 Angers St Etienne 2.25 3.50 3.62 2.18 3.29 3.44 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN France 1 2022
2022-01-26 Seraing Beerschot VA 2.06 3.90 3.60 2.01 3.63 3.42 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Belgium 1 2022
2022-01-26 Anderlecht Cercle Brugge 1.70 4.25 5.00 1.65 4.00 4.83 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Belgium 1 2022
2022-01-26 Waregem Oud-Heverlee Leuven 2.76 3.79 2.50 2.68 3.58 2.42 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Belgium 1 2022
2022-01-26 Eupen Standard 3.15 3.69 2.32 3.01 3.41 2.27 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Belgium 1 2022
2022-01-26 Rangers Livingston 1.18 8.30 22.55 1.16 7.11 16.96 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Scotland 4 2022
2022-01-26 St Johnstone Dundee 2.40 3.25 3.45 2.33 3.08 3.23 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Scotland 4 2022
2022-01-26 Lecce Vicenza 1.40 5.00 9.75 1.36 4.69 8.17 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Italy 2 2022
2022-01-26 Motherwell Hibernian 3.35 3.48 2.32 3.20 3.23 2.26 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Scotland 4 2022
2022-01-27 Estoril Arouca 2.05 3.66 4.00 1.98 3.36 3.79 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Portugal 1 2022
2022-01-27 Club Brugge St. Gilloise 2.08 3.92 3.50 2.03 3.65 3.34 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN Belgium 1 2022


The market average odds:

market_average__away_win__odds market_average__draw__odds market_average__home_win__odds market_average__over_2.5__odds market_average__under_2.5__odds
0 5.70 3.81 1.62 2.03 1.78
1 2.44 3.14 2.92 2.19 1.64
2 2.99 3.20 2.40 2.11 1.71
3 1.71 3.81 4.64 1.81 1.98
4 3.44 3.29 2.18 2.23 1.66
5 3.42 3.63 2.01 1.79 2.00
6 4.83 4.00 1.65 1.73 2.09
7 2.42 3.58 2.68 1.48 2.55
8 2.27 3.41 3.01 1.77 2.02
9 16.96 7.11 1.16 1.59 2.31
10 3.23 3.08 2.33 2.52 1.50
11 8.17 4.69 1.36 1.72 2.07
12 2.26 3.23 3.20 2.18 1.66
13 3.79 3.36 1.98 2.21 1.65
14 3.34 3.65 2.03 1.63 2.24


Total running time of the script: ( 0 minutes 23.907 seconds)

Gallery generated by Sphinx-Gallery