Skip to content

Commit

Permalink
Support Weights and Improve Time Complexity of Prediction Methods (#138)
Browse files Browse the repository at this point in the history
* Add support for weights and balance flags. Also improved the time complexity of prediction functions.

Signed-off-by: Vivek Joshy <[email protected]>

* Format with black and add changelog fragments.

Signed-off-by: Vivek Joshy <[email protected]>

* Remove missing 3.14 version key

Signed-off-by: Vivek Joshy <[email protected]>

---------

Signed-off-by: Vivek Joshy <[email protected]>
  • Loading branch information
vivekjoshy authored Jul 15, 2024
1 parent cc684f1 commit 9d49c29
Show file tree
Hide file tree
Showing 46 changed files with 2,976 additions and 2,015 deletions.
3 changes: 1 addition & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github: OpenDebates
open_collective: openskill
github: vivekjoshy
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report
about: Create a report to help us improve
title: ''
labels: 'maybe: bug'
assignees: daegontaven
assignees: vivekjoshy

---

Expand All @@ -21,8 +21,8 @@ If applicable, add screenshots to help explain your problem.

**Platform Information**
- OS: [e.g. Ubuntu]
- Python Version: [e.g. 3.10]
- openskill.py Version: [e.g. 0.2.0-alpha.0]
- Python Version: [e.g. 3.12]
- openskill.py Version: [e.g. 5.0.2]

**Additional context**
Add any other context about the problem here.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: daegontaven
assignees: vivekjoshy

---

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: Draft Paper
on: [push]

jobs:
Expand All @@ -6,14 +7,14 @@ jobs:
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: paper
path: paper/paper.pdf
29 changes: 15 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@ jobs:
fail-fast: false
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
architecture: ["x86", "x64"]
experimental: [false]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Stable CPython - ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: 'pip'
cache-dependency-path: "**/pyproject.toml"
- name: Install Tox
run: python -m pip install tox-gh-actions>=3.1.3
run: python -m pip install tox-gh-actions>=3.2.0
- name: Setup Test Suite
run: tox -vv --notest
- name: Run Tests
Expand All @@ -45,7 +46,7 @@ jobs:
tox --skip-pkg-install
continue-on-error: ${{ matrix.experimental }}
- name: "Upload Coverage to Codecov"
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ !matrix.experimental }}
Expand All @@ -66,17 +67,17 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Unstable CPython - ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: "**/pyproject.toml"
- name: Install Tox
run: python -m pip install tox-gh-actions>=3.1.3
run: python -m pip install tox-gh-actions>=3.2.0
- name: Setup Test Suite
run: tox -vv --notest
- name: Run Tests
Expand All @@ -85,7 +86,7 @@ jobs:
tox --skip-pkg-install
continue-on-error: ${{ matrix.experimental }}
- name: "Upload Coverage to Codecov"
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ !matrix.experimental }}
Expand All @@ -99,24 +100,24 @@ jobs:
fail-fast: true
matrix:
os: [Ubuntu, MacOS, Windows]
python-version: ["pypy3.8", "pypy3.9", "pypy3.10"]
python-version: ["pypy3.9", "pypy3.10"]
architecture: ["x64"]
experimental: [false]
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up PyPy - ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: "**/pyproject.toml"
- name: Install Tox
run: python -m pip install tox-gh-actions>=3.1.3
run: python -m pip install tox-gh-actions>=3.2.0
- name: Setup Test Suite
run: tox -vv --notest
- name: Run Tests
Expand All @@ -125,7 +126,7 @@ jobs:
tox --skip-pkg-install
continue-on-error: ${{ matrix.experimental }}
- name: "Upload Coverage to Codecov"
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ !matrix.experimental }}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get Tag
id: tag
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Set Up Python 3.11
uses: actions/setup-python@v4
- name: Set Up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Vivek Joshy
Copyright (c) 2024 Vivek Joshy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ and bury Elo once and for all:
- Multifaction.
- Asymmetric faction size.
- Predict Win, Draw and Rank Outcomes.
- Per Player Weights
- Partial Play
- 150% faster than TrueSkill.
- 100% Pure Python.
- 100% Test Coverage.
- CPython and PyPy Support.
- 5 Separate Models.
- Fine-grained control of mathematical constants.
- Open License
- Up to 7% more accurate than TrueSkill.
- Accuracy on par with TrueSkill.


## Installation
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

## Reporting a Vulnerability

Submit any sensitive issues through private vulnerability reporting or send an email to [`[email protected]`](mailto:[email protected]).
Submit any sensitive issues through private vulnerability reporting or send an email to [`[email protected]`](mailto:[email protected]).
1 change: 1 addition & 0 deletions changes/138.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prediction methods better account for uncertainty.
2 changes: 2 additions & 0 deletions changes/138.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Support Per Player Weights and Balance Flag
Prediction methods have faster runtime.
18 changes: 9 additions & 9 deletions docs/doc_requires.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
sphinx~=7.2
sphinx~=7.4
nbsphinx~=0.9
pygments~=2.15
shibuya~=2024.4
ipykernel~=6.25
myst_parser~=2.0 # Must Be Underscore, not Hyphen
sphinx-intl~=2.1
pygments~=2.18
shibuya~=2024.7
ipykernel~=6.29
myst_parser~=3.0 # Must Be Underscore, not Hyphen
sphinx-intl~=2.2
sphinx_favicon~=1.0
sphinx-copybutton~=0.5
sphinx-autoapi~=3.0
sphinxext-opengraph~=0.8
sphinx-autoapi~=3.1
sphinxext-opengraph~=0.9
sphinxcontrib-bibtex~=2.6
sphinx-autodoc-typehints~=2.0
sphinx-autodoc-typehints~=2.2
22 changes: 7 additions & 15 deletions docs/source/api/openskill/models/common/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,12 @@ Functions

.. autoapisummary::

openskill.models.common._arg_sort
openskill.models.common._matrix_transpose
openskill.models.common._rank_data
openskill.models.common._normalize
openskill.models.common._unary_minus



.. py:function:: _arg_sort(vector)
Returns the indices that would sort a vector.

:param vector: A list of objects.
:return: Rank vector without ties.


.. py:function:: _matrix_transpose(matrix)
Transpose a matrix.
Expand All @@ -41,13 +32,14 @@ Functions
:return: A transposed matrix.


.. py:function:: _rank_data(vector)
.. py:function:: _normalize(vector, target_minimum, target_maximum)
Sorting with 'competition ranking'. Pure python equivalent of
:code:`scipy.stats.rankdata` function.
Normalizes a vector to a target range of values.

:param vector: A list of objects.
:return: Rank vector with ties.
:param vector: A vector to normalize.
:param target_minimum: Minimum value to scale the values between.
:param target_maximum: Maximum value to scale the values between.
:return: Normalized vector.


.. py:function:: _unary_minus(number)
Expand Down
Loading

0 comments on commit 9d49c29

Please sign in to comment.