Skip to main content

Python sports betting toolbox.

Project description

sports-betting

ci doc

Category Tools
Development black ruff mypy docformatter
Package version pythonversion downloads
Documentation mkdocs
Communication gitter discussions

Introduction

Python sports betting toolbox.

The sports-betting package is a collection of tools that makes it easy to create machine learning models for sports betting and evaluate their performance. It is compatible with scikit-learn.

Installation

For user installation, sports-betting is currently available on the PyPi's repository, and you can install it via pip:

pip install sports-betting

Development installation requires to clone the repository and then use PDM to install the project as well as the main and development dependencies:

git clone https://github.com/georgedouzas/sports-betting.git
cd sports-betting
pdm install

Usage

API

The sports-betting package makes it easy to download sports betting data:

from sportsbet.datasets import SoccerDataLoader
dataloader = SoccerDataLoader(param_grid={'league': ['Italy'], 'year': [2020]})
X_train, Y_train, O_train = dataloader.extract_train_data(odds_type='market_maximum', drop_na_thres=1.0)
X_fix, Y_fix, O_fix = dataloader.extract_fixtures_data()

X_train are the historical/training data and X_fix are the test/fixtures data. The historical data can be used to backtest the performance of a bettor model:

from sportsbet.evaluation import ClassifierBettor
from sklearn.dummy import DummyClassifier
bettor = ClassifierBettor(DummyClassifier())
bettor.backtest(X_train, Y_train, O_train)

We can use the trained bettor model to predict the value bets using the fixtures data:

bettor.bet(X_fix, O_fix)

CLI

The command sportsbet provides various sub-commands to download data and predict the value bets. For any sub-command you may add the --help flag to get more information about its usage.

Dataloader

Show available sports names:

sportsbet dataloader names

Show available parameters for dataloaders:

sportsbet dataloader params --name soccer

Select some of the above parameters and create a dataloader:

sportsbet dataloader create --name soccer --dataloader-path /path/dataloader.pkl --param-grid "league: Italy, Spain | year: 2021, 2022" --param-grid "league: Greece"

Show available odds types for the above dataloader:

sportsbet dataloader odds-types --dataloader-path /path/dataloader.pkl

Show and export training data:

sportsbet dataloader training --odds-type bet365 --drop-na-thres 1.0 --dataloader-path /path/dataloader.pkl --data-path /another/path/directory

Show and export fixtures data:

sportsbet dataloader fixtures --dataloader-path /path/dataloader.pkl --data-path /another/path/directory

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sports-betting-0.3.1.tar.gz (35.8 kB view hashes)

Uploaded Source

Built Distribution

sports_betting-0.3.1-py3-none-any.whl (36.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page