mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-30 18:59:10 +00:00
5fd5e32cb1
* Create python-publish.yml
* populated publish-analysis.yml
moved legacy versions of analysis to seperate subfolder
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* attempt to fix issue with publish action
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* another attempt o fix publish-analysis.yml
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* this should work now
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* pypa can't take just one package so i'm trying all
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* this should totally work now
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* trying removing custom dir
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* rename analysis to tra_analysis, bump version to 2.0.0
* remove old packages which are already on github releases
* remove pycache
* removed ipynb_checkpoints
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
* build
* do the dir thing
* trying removing custom dir
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
Signed-off-by: Dev Singh <dev@devksingh.com>
* rename analysis to tra_analysis, bump version to 2.0.0
Signed-off-by: Dev Singh <dev@devksingh.com>
* remove old packages which are already on github releases
Signed-off-by: Dev Singh <dev@devksingh.com>
* remove pycache
Signed-off-by: Dev Singh <dev@devksingh.com>
* build
Signed-off-by: Dev Singh <dev@devksingh.com>
* removed ipynb_checkpoints
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
Signed-off-by: Dev Singh <dev@devksingh.com>
* do the dir thing
Signed-off-by: Dev Singh <dev@devksingh.com>
* Revert "do the dir thing"
This reverts commit 2eb7ffca8d
.
* correct dir
* set correct yaml positions
Signed-off-by: Dev Singh <dev@devksingh.com>
* attempt to set correct dir
Signed-off-by: Dev Singh <dev@devksingh.com>
* run on tags only
Signed-off-by: Dev Singh <dev@devksingh.com>
* remove all caches from vcs
Signed-off-by: Dev Singh <dev@devksingh.com>
* bump version for testing
Signed-off-by: Dev Singh <dev@devksingh.com>
* remove broke build
Signed-off-by: Dev Singh <dev@devksingh.com>
* dont upload dists to github
Signed-off-by: Dev Singh <dev@devksingh.com>
* bump to 2.0.2 for testing
Signed-off-by: Dev Singh <dev@devksingh.com>
* fix yaml
Signed-off-by: Dev Singh <dev@devksingh.com>
* update docs
Signed-off-by: Dev Singh <dev@devksingh.com>
* add to readme
Signed-off-by: Dev Singh <dev@devksingh.com>
* run only on master
Signed-off-by: Dev Singh <dev@devksingh.com>
Co-authored-by: Arthur Lu <learthurgo@gmail.com>
Co-authored-by: Dev Singh <dsingh@CentaurusRidge.localdomain>
99 lines
2.5 KiB
Python
99 lines
2.5 KiB
Python
import math
|
|
|
|
class Glicko2:
|
|
_tau = 0.5
|
|
|
|
def getRating(self):
|
|
return (self.__rating * 173.7178) + 1500
|
|
|
|
def setRating(self, rating):
|
|
self.__rating = (rating - 1500) / 173.7178
|
|
|
|
rating = property(getRating, setRating)
|
|
|
|
def getRd(self):
|
|
return self.__rd * 173.7178
|
|
|
|
def setRd(self, rd):
|
|
self.__rd = rd / 173.7178
|
|
|
|
rd = property(getRd, setRd)
|
|
|
|
def __init__(self, rating = 1500, rd = 350, vol = 0.06):
|
|
|
|
self.setRating(rating)
|
|
self.setRd(rd)
|
|
self.vol = vol
|
|
|
|
def _preRatingRD(self):
|
|
|
|
self.__rd = math.sqrt(math.pow(self.__rd, 2) + math.pow(self.vol, 2))
|
|
|
|
def update_player(self, rating_list, RD_list, outcome_list):
|
|
|
|
rating_list = [(x - 1500) / 173.7178 for x in rating_list]
|
|
RD_list = [x / 173.7178 for x in RD_list]
|
|
|
|
v = self._v(rating_list, RD_list)
|
|
self.vol = self._newVol(rating_list, RD_list, outcome_list, v)
|
|
self._preRatingRD()
|
|
|
|
self.__rd = 1 / math.sqrt((1 / math.pow(self.__rd, 2)) + (1 / v))
|
|
|
|
tempSum = 0
|
|
for i in range(len(rating_list)):
|
|
tempSum += self._g(RD_list[i]) * \
|
|
(outcome_list[i] - self._E(rating_list[i], RD_list[i]))
|
|
self.__rating += math.pow(self.__rd, 2) * tempSum
|
|
|
|
|
|
def _newVol(self, rating_list, RD_list, outcome_list, v):
|
|
|
|
i = 0
|
|
delta = self._delta(rating_list, RD_list, outcome_list, v)
|
|
a = math.log(math.pow(self.vol, 2))
|
|
tau = self._tau
|
|
x0 = a
|
|
x1 = 0
|
|
|
|
while x0 != x1:
|
|
# New iteration, so x(i) becomes x(i-1)
|
|
x0 = x1
|
|
d = math.pow(self.__rating, 2) + v + math.exp(x0)
|
|
h1 = -(x0 - a) / math.pow(tau, 2) - 0.5 * math.exp(x0) \
|
|
/ d + 0.5 * math.exp(x0) * math.pow(delta / d, 2)
|
|
h2 = -1 / math.pow(tau, 2) - 0.5 * math.exp(x0) * \
|
|
(math.pow(self.__rating, 2) + v) \
|
|
/ math.pow(d, 2) + 0.5 * math.pow(delta, 2) * math.exp(x0) \
|
|
* (math.pow(self.__rating, 2) + v - math.exp(x0)) / math.pow(d, 3)
|
|
x1 = x0 - (h1 / h2)
|
|
|
|
return math.exp(x1 / 2)
|
|
|
|
def _delta(self, rating_list, RD_list, outcome_list, v):
|
|
|
|
tempSum = 0
|
|
for i in range(len(rating_list)):
|
|
tempSum += self._g(RD_list[i]) * (outcome_list[i] - self._E(rating_list[i], RD_list[i]))
|
|
return v * tempSum
|
|
|
|
def _v(self, rating_list, RD_list):
|
|
|
|
tempSum = 0
|
|
for i in range(len(rating_list)):
|
|
tempE = self._E(rating_list[i], RD_list[i])
|
|
tempSum += math.pow(self._g(RD_list[i]), 2) * tempE * (1 - tempE)
|
|
return 1 / tempSum
|
|
|
|
def _E(self, p2rating, p2RD):
|
|
|
|
return 1 / (1 + math.exp(-1 * self._g(p2RD) * \
|
|
(self.__rating - p2rating)))
|
|
|
|
def _g(self, RD):
|
|
|
|
return 1 / math.sqrt(1 + 3 * math.pow(RD, 2) / math.pow(math.pi, 2))
|
|
|
|
def did_not_compete(self):
|
|
|
|
self._preRatingRD() |