sportsfeatures


Namesportsfeatures JSON
Version 0.0.116 PyPI version JSON
download
home_pagehttps://github.com/8W9aG/sports-features
SummaryA library for processing sports features over a dataframe containing sports data.
upload_time2025-10-07 16:50:29
maintainerNone
docs_urlNone
authorWill Sackfield
requires_pythonNone
licenseMIT
keywords features sports
VCS
bugtrack_url
requirements openskill pandas feature-engine tqdm scikit-learn geopy numpy pytest-is-running joblib timeseriesfeatures textfeats scipy imagefeatures requests-cache
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sports-features

<a href="https://pypi.org/project/sportsfeatures/">
    <img alt="PyPi" src="https://img.shields.io/pypi/v/sportsfeatures">
</a>

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

## Dependencies :globe_with_meridians:

Python 3.11.6:

- [openskill](https://openskill.me/en/latest/index.html)
- [pandas](https://pandas.pydata.org/)
- [feature-engine](https://feature-engine.trainindata.com/en/latest/)
- [tqdm](https://github.com/tqdm/tqdm)
- [scikit-learn](https://scikit-learn.org/)
- [geopy](https://geopy.readthedocs.io/en/stable/)
- [numpy](https://numpy.org/)
- [pytest-is-running](https://github.com/adamchainz/pytest-is-running)
- [joblib](https://joblib.readthedocs.io/en/stable/)
- [timeseries-features](https://github.com/8W9aG/timeseries-features)
- [textfeats](https://github.com/8W9aG/text-features)
- [scipy](https://scipy.org/)
- [image-features](https://github.com/8W9aG/image-features)
- [requests-cache](https://requests-cache.readthedocs.io/en/stable/)

## Raison D'ĂȘtre :thought_balloon:

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

## Architecture :triangular_ruler:

`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](https://openskill.me/en/latest/index.html). 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 :inbox_tray:

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 :eyes:

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:

```python
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 :memo:

The project is available under the [MIT License](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/8W9aG/sports-features",
    "name": "sportsfeatures",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "features, sports",
    "author": "Will Sackfield",
    "author_email": "will.sackfield@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/37/63/d9d1f9c315a7a398bbb96ebf3bb6d15ecd2e7e1bbd3596cdef18ee1d4a60/sportsfeatures-0.0.116.tar.gz",
    "platform": null,
    "description": "# sports-features\n\n<a href=\"https://pypi.org/project/sportsfeatures/\">\n    <img alt=\"PyPi\" src=\"https://img.shields.io/pypi/v/sportsfeatures\">\n</a>\n\nA library for processing sports features over a dataframe containing sports data.\n\n## Dependencies :globe_with_meridians:\n\nPython 3.11.6:\n\n- [openskill](https://openskill.me/en/latest/index.html)\n- [pandas](https://pandas.pydata.org/)\n- [feature-engine](https://feature-engine.trainindata.com/en/latest/)\n- [tqdm](https://github.com/tqdm/tqdm)\n- [scikit-learn](https://scikit-learn.org/)\n- [geopy](https://geopy.readthedocs.io/en/stable/)\n- [numpy](https://numpy.org/)\n- [pytest-is-running](https://github.com/adamchainz/pytest-is-running)\n- [joblib](https://joblib.readthedocs.io/en/stable/)\n- [timeseries-features](https://github.com/8W9aG/timeseries-features)\n- [textfeats](https://github.com/8W9aG/text-features)\n- [scipy](https://scipy.org/)\n- [image-features](https://github.com/8W9aG/image-features)\n- [requests-cache](https://requests-cache.readthedocs.io/en/stable/)\n\n## Raison D'\u00eatre :thought_balloon:\n\n`sportsfeatures` aims to process features relevant to predicting aspects of sporting games.\n\n## Architecture :triangular_ruler:\n\n`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:\n\n1. Process the player and teams skill levels using [OpenSkill](https://openskill.me/en/latest/index.html). This is an ELO like rating system giving a probability of win and loss.\n2. Compute the offensive efficiency of each team/player.\n3. 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.\n4. Compute the datetime features for any datetime columns.\n5. Remove the lookahead features.\n\n## Installation :inbox_tray:\n\nThis is a python package hosted on pypi, so to install simply run the following command:\n\n`pip install sportsfeatures`\n\nor install using this local repository:\n\n`python setup.py install --old-and-unmanageable`\n\n## Usage example :eyes:\n\nThe 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.\n\n### Generating Features\n\nTo generate features:\n\n```python\nimport datetime\n\nimport pandas as pd\n\nfrom sportsfeatures.process import process\nfrom sportsfeatures.identifier import Identifier\nfrom sportsfeatures.entity_type import EntityType\n\ndf = ... # Your sports data\nidentifiers = [\n    Identifier(EntityType.TEAM, \"teams/0/id\", [\"teams/0/kicks\"], \"teams/0\"),\n    Identifier(EntityType.TEAM, \"teams/1/id\", [\"teams/1/kicks\"], \"teams/1\"),\n]\ndf = process(df, identifiers, [datetime.timedelta(days=365), None], \"dt\")\n```\n\nThis will produce a dataframe that contains the new sports related features.\n\n## License :memo:\n\nThe project is available under the [MIT License](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for processing sports features over a dataframe containing sports data.",
    "version": "0.0.116",
    "project_urls": {
        "Homepage": "https://github.com/8W9aG/sports-features"
    },
    "split_keywords": [
        "features",
        " sports"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3763d9d1f9c315a7a398bbb96ebf3bb6d15ecd2e7e1bbd3596cdef18ee1d4a60",
                "md5": "03e3ce85bf7dbde5a9a07dcf7f917c78",
                "sha256": "d30a3e6a7882d4a237c0e88a51943e6d37b42f8fc1165f006fea32fe5b3ea7b3"
            },
            "downloads": -1,
            "filename": "sportsfeatures-0.0.116.tar.gz",
            "has_sig": false,
            "md5_digest": "03e3ce85bf7dbde5a9a07dcf7f917c78",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25301,
            "upload_time": "2025-10-07T16:50:29",
            "upload_time_iso_8601": "2025-10-07T16:50:29.104904Z",
            "url": "https://files.pythonhosted.org/packages/37/63/d9d1f9c315a7a398bbb96ebf3bb6d15ecd2e7e1bbd3596cdef18ee1d4a60/sportsfeatures-0.0.116.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-07 16:50:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "8W9aG",
    "github_project": "sports-features",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "openskill",
            "specs": [
                [
                    ">=",
                    "6.0.2"
                ]
            ]
        },
        {
            "name": "pandas",
            "specs": [
                [
                    ">=",
                    "2.2.3"
                ]
            ]
        },
        {
            "name": "feature-engine",
            "specs": [
                [
                    ">=",
                    "1.8.3"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    ">=",
                    "4.67.1"
                ]
            ]
        },
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "1.5.2"
                ]
            ]
        },
        {
            "name": "geopy",
            "specs": [
                [
                    ">=",
                    "2.4.1"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.26.4"
                ]
            ]
        },
        {
            "name": "pytest-is-running",
            "specs": [
                [
                    ">=",
                    "1.5.1"
                ]
            ]
        },
        {
            "name": "joblib",
            "specs": [
                [
                    ">=",
                    "1.4.2"
                ]
            ]
        },
        {
            "name": "timeseriesfeatures",
            "specs": [
                [
                    ">=",
                    "0.0.17"
                ]
            ]
        },
        {
            "name": "textfeats",
            "specs": [
                [
                    ">=",
                    "0.1.4"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "1.15.2"
                ]
            ]
        },
        {
            "name": "imagefeatures",
            "specs": [
                [
                    ">=",
                    "0.0.2"
                ]
            ]
        },
        {
            "name": "requests-cache",
            "specs": [
                [
                    ">=",
                    "1.2.1"
                ]
            ]
        }
    ],
    "lcname": "sportsfeatures"
}
        
Elapsed time: 2.07758s