Skip to main content

sports-features

PyPi

A library for processing sports features over a dataframe containing sports data.

Dependencies 🌐

Python 3.11.6:

Raison D'être 💭

sportsfeatures aims to process features relevant to predicting aspects of sporting games.

Architecture 📐

sportsfeatures is a functional library, meaning that each phase of feature extraction gets put through a different function until the final output. It contains some caching when the processing is heavy (such as skill processing). The features its computes are as follows:

  1. Process the player and teams skill levels using OpenSkill. This is an ELO like rating system giving a probability of win and loss.
  2. Compute the offensive efficiency of each team/player.
  3. Compute the time series values of the numeric features for each team/player over the various windows provided. This includes lag, count, sum, mean, median, var, std, min, max, skew, kurt, sem, rank.
  4. Compute the datetime features for any datetime columns.
  5. Remove the lookahead features.

Installation 📥

This is a python package hosted on pypi, so to install simply run the following command:

pip install sportsfeatures

or install using this local repository:

python setup.py install --old-and-unmanageable

Usage example 👀

The use of sportsfeatures is entirely through code due to it being a library. It attempts to hide most of its complexity from the user, so it only has a few functions of relevance in its outward API.

Generating Features

To generate features:

import datetime

import pandas as pd

from sportsfeatures.process import process
from sportsfeatures.identifier import Identifier
from sportsfeatures.entity_type import EntityType

df = ... # Your sports data
identifiers = [
    Identifier(EntityType.TEAM, "teams/0/id", ["teams/0/kicks"], "teams/0"),
    Identifier(EntityType.TEAM, "teams/1/id", ["teams/1/kicks"], "teams/1"),
]
df = process(df, identifiers, [datetime.timedelta(days=365), None], "dt")

This will produce a dataframe that contains the new sports related features.

License 📝

The project is available under the MIT License.

Metadata

Release files for sportsfeatures 0.0.120

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sportsfeatures 0.0.120
File Size Uploaded Provenance
sportsfeatures-0.0.120.tar.gz 25.4 kB Without provenance Details

Release files / sportsfeatures-0.0.120.tar.gz

Download URL sportsfeatures-0.0.120.tar.gz
Size 25.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2a11dba1c47fde1a4f6e1951daa06a6c5b5e6cb35e403399805d103bf598d6c9
BLAKE2b-256 checksum
How to use checksums
1851f011a8fabdb204355ecf98d5e144ebf177118da49a5827048372a98648b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.6

Security for sportsfeatures 0.0.120

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.120 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page