mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-07 07:27:20 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7a58cd08e2 | ||
|
337fae68ee | ||
|
5e71d05626 | ||
|
01df42aa49 | ||
|
33eea153c1 | ||
|
114eee5d57 | ||
|
06f008746a | ||
|
4f9c4e0dbb | ||
|
5697e8b79e | ||
|
e054e66743 | ||
|
c914bd3754 | ||
|
6c08885a53 |
2
.devcontainer/Dockerfile
Normal file
2
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FROM python
|
||||||
|
WORKDIR ~/
|
26
.devcontainer/devcontainer.json
Normal file
26
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "TRA Analysis Development Environment",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile",
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.shell.linux": "/bin/bash",
|
||||||
|
"python.pythonPath": "/usr/local/bin/python",
|
||||||
|
"python.linting.enabled": true,
|
||||||
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
|
||||||
|
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
|
||||||
|
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
|
||||||
|
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
|
||||||
|
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
|
||||||
|
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
|
||||||
|
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
|
||||||
|
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
||||||
|
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
|
||||||
|
"python.testing.pytestPath": "/usr/local/py-utils/bin/pytest"
|
||||||
|
},
|
||||||
|
"extensions": [
|
||||||
|
"mhutchie.git-graph",
|
||||||
|
],
|
||||||
|
"postCreateCommand": "pip install -r analysis-master/analysis-amd64/requirements.txt"
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: analysis
|
Name: analysis
|
||||||
Version: 1.0.0.9
|
Version: 1.0.0.11
|
||||||
Summary: analysis package developed by Titan Scouting for The Red Alliance
|
Summary: analysis package developed by Titan Scouting for The Red Alliance
|
||||||
Home-page: https://github.com/titanscout2022/tr2022-strategy
|
Home-page: https://github.com/titanscout2022/tr2022-strategy
|
||||||
Author: The Titan Scouting Team
|
Author: The Titan Scouting Team
|
@@ -1,6 +1,7 @@
|
|||||||
setup.py
|
setup.py
|
||||||
analysis/__init__.py
|
analysis/__init__.py
|
||||||
analysis/analysis.py
|
analysis/analysis.py
|
||||||
|
analysis/glicko2.py
|
||||||
analysis/regression.py
|
analysis/regression.py
|
||||||
analysis/titanlearn.py
|
analysis/titanlearn.py
|
||||||
analysis/trueskill.py
|
analysis/trueskill.py
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,10 +7,14 @@
|
|||||||
# current benchmark of optimization: 1.33 times faster
|
# current benchmark of optimization: 1.33 times faster
|
||||||
# setup:
|
# setup:
|
||||||
|
|
||||||
__version__ = "1.1.13.007"
|
__version__ = "1.1.13.009"
|
||||||
|
|
||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
|
1.1.13.009:
|
||||||
|
- moved elo, glicko2, trueskill functions under class Metrics
|
||||||
|
1.1.13.008:
|
||||||
|
- moved Glicko2 to a seperate package
|
||||||
1.1.13.007:
|
1.1.13.007:
|
||||||
- fixed bug with trueskill
|
- fixed bug with trueskill
|
||||||
1.1.13.006:
|
1.1.13.006:
|
||||||
@@ -271,7 +275,6 @@ __all__ = [
|
|||||||
'SVM',
|
'SVM',
|
||||||
'random_forest_classifier',
|
'random_forest_classifier',
|
||||||
'random_forest_regressor',
|
'random_forest_regressor',
|
||||||
'Glicko2',
|
|
||||||
# all statistics functions left out due to integration in other functions
|
# all statistics functions left out due to integration in other functions
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -280,6 +283,7 @@ __all__ = [
|
|||||||
# imports (now in alphabetical order! v 1.0.3.006):
|
# imports (now in alphabetical order! v 1.0.3.006):
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
|
from analysis import glicko2 as Glicko2
|
||||||
import numba
|
import numba
|
||||||
from numba import jit
|
from numba import jit
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -444,32 +448,34 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
return regressions
|
return regressions
|
||||||
|
|
||||||
def elo(starting_score, opposing_score, observed, N, K):
|
class Metrics:
|
||||||
|
|
||||||
expected = 1/(1+10**((np.array(opposing_score) - starting_score)/N))
|
def elo(starting_score, opposing_score, observed, N, K):
|
||||||
|
|
||||||
return starting_score + K*(np.sum(observed) - np.sum(expected))
|
expected = 1/(1+10**((np.array(opposing_score) - starting_score)/N))
|
||||||
|
|
||||||
def glicko2(starting_score, starting_rd, starting_vol, opposing_score, opposing_rd, observations):
|
return starting_score + K*(np.sum(observed) - np.sum(expected))
|
||||||
|
|
||||||
player = Glicko2(rating = starting_score, rd = starting_rd, vol = starting_vol)
|
def glicko2(starting_score, starting_rd, starting_vol, opposing_score, opposing_rd, observations):
|
||||||
|
|
||||||
player.update_player([x for x in opposing_score], [x for x in opposing_rd], observations)
|
player = Glicko2.Glicko2(rating = starting_score, rd = starting_rd, vol = starting_vol)
|
||||||
|
|
||||||
return (player.rating, player.rd, player.vol)
|
player.update_player([x for x in opposing_score], [x for x in opposing_rd], observations)
|
||||||
|
|
||||||
def trueskill(teams_data, observations): # teams_data is array of array of tuples ie. [[(mu, sigma), (mu, sigma), (mu, sigma)], [(mu, sigma), (mu, sigma), (mu, sigma)]]
|
return (player.rating, player.rd, player.vol)
|
||||||
|
|
||||||
team_ratings = []
|
def trueskill(teams_data, observations): # teams_data is array of array of tuples ie. [[(mu, sigma), (mu, sigma), (mu, sigma)], [(mu, sigma), (mu, sigma), (mu, sigma)]]
|
||||||
|
|
||||||
for team in teams_data:
|
team_ratings = []
|
||||||
team_temp = ()
|
|
||||||
for player in team:
|
|
||||||
player = Trueskill.Rating(player[0], player[1])
|
|
||||||
team_temp = team_temp + (player,)
|
|
||||||
team_ratings.append(team_temp)
|
|
||||||
|
|
||||||
return Trueskill.rate(team_ratings, ranks=observations)
|
for team in teams_data:
|
||||||
|
team_temp = ()
|
||||||
|
for player in team:
|
||||||
|
player = Trueskill.Rating(player[0], player[1])
|
||||||
|
team_temp = team_temp + (player,)
|
||||||
|
team_ratings.append(team_temp)
|
||||||
|
|
||||||
|
return Trueskill.rate(team_ratings, ranks=observations)
|
||||||
|
|
||||||
class RegressionMetrics():
|
class RegressionMetrics():
|
||||||
|
|
||||||
@@ -561,24 +567,25 @@ def decisiontree(data, labels, test_size = 0.3, criterion = "gini", splitter = "
|
|||||||
|
|
||||||
return model, metrics
|
return model, metrics
|
||||||
|
|
||||||
@jit(forceobj=True)
|
class KNN:
|
||||||
def knn_classifier(data, labels, test_size = 0.3, algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=None, n_neighbors=5, p=2, weights='uniform'): #expects *2d data and 1d labels post-scaling
|
|
||||||
|
|
||||||
data_train, data_test, labels_train, labels_test = sklearn.model_selection.train_test_split(data, labels, test_size=test_size, random_state=1)
|
def knn_classifier(data, labels, test_size = 0.3, algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=None, n_neighbors=5, p=2, weights='uniform'): #expects *2d data and 1d labels post-scaling
|
||||||
model = sklearn.neighbors.KNeighborsClassifier()
|
|
||||||
model.fit(data_train, labels_train)
|
|
||||||
predictions = model.predict(data_test)
|
|
||||||
|
|
||||||
return model, ClassificationMetrics(predictions, labels_test)
|
data_train, data_test, labels_train, labels_test = sklearn.model_selection.train_test_split(data, labels, test_size=test_size, random_state=1)
|
||||||
|
model = sklearn.neighbors.KNeighborsClassifier()
|
||||||
|
model.fit(data_train, labels_train)
|
||||||
|
predictions = model.predict(data_test)
|
||||||
|
|
||||||
def knn_regressor(data, outputs, test_size, n_neighbors = 5, weights = "uniform", algorithm = "auto", leaf_size = 30, p = 2, metric = "minkowski", metric_params = None, n_jobs = None):
|
return model, ClassificationMetrics(predictions, labels_test)
|
||||||
|
|
||||||
data_train, data_test, outputs_train, outputs_test = sklearn.model_selection.train_test_split(data, outputs, test_size=test_size, random_state=1)
|
def knn_regressor(data, outputs, test_size, n_neighbors = 5, weights = "uniform", algorithm = "auto", leaf_size = 30, p = 2, metric = "minkowski", metric_params = None, n_jobs = None):
|
||||||
model = sklearn.neighbors.KNeighborsRegressor(n_neighbors = n_neighbors, weights = weights, algorithm = algorithm, leaf_size = leaf_size, p = p, metric = metric, metric_params = metric_params, n_jobs = n_jobs)
|
|
||||||
model.fit(data_train, outputs_train)
|
|
||||||
predictions = model.predict(data_test)
|
|
||||||
|
|
||||||
return model, RegressionMetrics(predictions, outputs_test)
|
data_train, data_test, outputs_train, outputs_test = sklearn.model_selection.train_test_split(data, outputs, test_size=test_size, random_state=1)
|
||||||
|
model = sklearn.neighbors.KNeighborsRegressor(n_neighbors = n_neighbors, weights = weights, algorithm = algorithm, leaf_size = leaf_size, p = p, metric = metric, metric_params = metric_params, n_jobs = n_jobs)
|
||||||
|
model.fit(data_train, outputs_train)
|
||||||
|
predictions = model.predict(data_test)
|
||||||
|
|
||||||
|
return model, RegressionMetrics(predictions, outputs_test)
|
||||||
|
|
||||||
class NaiveBayes:
|
class NaiveBayes:
|
||||||
|
|
||||||
@@ -690,103 +697,4 @@ def random_forest_regressor(data, outputs, test_size, n_estimators="warn", crite
|
|||||||
kernel.fit(data_train, outputs_train)
|
kernel.fit(data_train, outputs_train)
|
||||||
predictions = kernel.predict(data_test)
|
predictions = kernel.predict(data_test)
|
||||||
|
|
||||||
return kernel, RegressionMetrics(predictions, outputs_test)
|
return kernel, RegressionMetrics(predictions, outputs_test)
|
||||||
|
|
||||||
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()
|
|
99
analysis-master/analysis-amd64/analysis/glicko2.py
Normal file
99
analysis-master/analysis-amd64/analysis/glicko2.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
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()
|
1
analysis-master/analysis-amd64/build.sh
Executable file
1
analysis-master/analysis-amd64/build.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
python setup.py sdist bdist_wheel || python3 setup.py sdist bdist_wheel
|
@@ -7,10 +7,14 @@
|
|||||||
# current benchmark of optimization: 1.33 times faster
|
# current benchmark of optimization: 1.33 times faster
|
||||||
# setup:
|
# setup:
|
||||||
|
|
||||||
__version__ = "1.1.13.007"
|
__version__ = "1.1.13.009"
|
||||||
|
|
||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
|
1.1.13.009:
|
||||||
|
- moved elo, glicko2, trueskill functions under class Metrics
|
||||||
|
1.1.13.008:
|
||||||
|
- moved Glicko2 to a seperate package
|
||||||
1.1.13.007:
|
1.1.13.007:
|
||||||
- fixed bug with trueskill
|
- fixed bug with trueskill
|
||||||
1.1.13.006:
|
1.1.13.006:
|
||||||
@@ -271,7 +275,6 @@ __all__ = [
|
|||||||
'SVM',
|
'SVM',
|
||||||
'random_forest_classifier',
|
'random_forest_classifier',
|
||||||
'random_forest_regressor',
|
'random_forest_regressor',
|
||||||
'Glicko2',
|
|
||||||
# all statistics functions left out due to integration in other functions
|
# all statistics functions left out due to integration in other functions
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -280,6 +283,7 @@ __all__ = [
|
|||||||
# imports (now in alphabetical order! v 1.0.3.006):
|
# imports (now in alphabetical order! v 1.0.3.006):
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
|
from analysis import glicko2 as Glicko2
|
||||||
import numba
|
import numba
|
||||||
from numba import jit
|
from numba import jit
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@@ -444,32 +448,34 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
return regressions
|
return regressions
|
||||||
|
|
||||||
def elo(starting_score, opposing_score, observed, N, K):
|
class Metrics:
|
||||||
|
|
||||||
expected = 1/(1+10**((np.array(opposing_score) - starting_score)/N))
|
def elo(starting_score, opposing_score, observed, N, K):
|
||||||
|
|
||||||
return starting_score + K*(np.sum(observed) - np.sum(expected))
|
expected = 1/(1+10**((np.array(opposing_score) - starting_score)/N))
|
||||||
|
|
||||||
def glicko2(starting_score, starting_rd, starting_vol, opposing_score, opposing_rd, observations):
|
return starting_score + K*(np.sum(observed) - np.sum(expected))
|
||||||
|
|
||||||
player = Glicko2(rating = starting_score, rd = starting_rd, vol = starting_vol)
|
def glicko2(starting_score, starting_rd, starting_vol, opposing_score, opposing_rd, observations):
|
||||||
|
|
||||||
player.update_player([x for x in opposing_score], [x for x in opposing_rd], observations)
|
player = Glicko2.Glicko2(rating = starting_score, rd = starting_rd, vol = starting_vol)
|
||||||
|
|
||||||
return (player.rating, player.rd, player.vol)
|
player.update_player([x for x in opposing_score], [x for x in opposing_rd], observations)
|
||||||
|
|
||||||
def trueskill(teams_data, observations): # teams_data is array of array of tuples ie. [[(mu, sigma), (mu, sigma), (mu, sigma)], [(mu, sigma), (mu, sigma), (mu, sigma)]]
|
return (player.rating, player.rd, player.vol)
|
||||||
|
|
||||||
team_ratings = []
|
def trueskill(teams_data, observations): # teams_data is array of array of tuples ie. [[(mu, sigma), (mu, sigma), (mu, sigma)], [(mu, sigma), (mu, sigma), (mu, sigma)]]
|
||||||
|
|
||||||
for team in teams_data:
|
team_ratings = []
|
||||||
team_temp = ()
|
|
||||||
for player in team:
|
|
||||||
player = Trueskill.Rating(player[0], player[1])
|
|
||||||
team_temp = team_temp + (player,)
|
|
||||||
team_ratings.append(team_temp)
|
|
||||||
|
|
||||||
return Trueskill.rate(team_ratings, ranks=observations)
|
for team in teams_data:
|
||||||
|
team_temp = ()
|
||||||
|
for player in team:
|
||||||
|
player = Trueskill.Rating(player[0], player[1])
|
||||||
|
team_temp = team_temp + (player,)
|
||||||
|
team_ratings.append(team_temp)
|
||||||
|
|
||||||
|
return Trueskill.rate(team_ratings, ranks=observations)
|
||||||
|
|
||||||
class RegressionMetrics():
|
class RegressionMetrics():
|
||||||
|
|
||||||
@@ -561,24 +567,25 @@ def decisiontree(data, labels, test_size = 0.3, criterion = "gini", splitter = "
|
|||||||
|
|
||||||
return model, metrics
|
return model, metrics
|
||||||
|
|
||||||
@jit(forceobj=True)
|
class KNN:
|
||||||
def knn_classifier(data, labels, test_size = 0.3, algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=None, n_neighbors=5, p=2, weights='uniform'): #expects *2d data and 1d labels post-scaling
|
|
||||||
|
|
||||||
data_train, data_test, labels_train, labels_test = sklearn.model_selection.train_test_split(data, labels, test_size=test_size, random_state=1)
|
def knn_classifier(data, labels, test_size = 0.3, algorithm='auto', leaf_size=30, metric='minkowski', metric_params=None, n_jobs=None, n_neighbors=5, p=2, weights='uniform'): #expects *2d data and 1d labels post-scaling
|
||||||
model = sklearn.neighbors.KNeighborsClassifier()
|
|
||||||
model.fit(data_train, labels_train)
|
|
||||||
predictions = model.predict(data_test)
|
|
||||||
|
|
||||||
return model, ClassificationMetrics(predictions, labels_test)
|
data_train, data_test, labels_train, labels_test = sklearn.model_selection.train_test_split(data, labels, test_size=test_size, random_state=1)
|
||||||
|
model = sklearn.neighbors.KNeighborsClassifier()
|
||||||
|
model.fit(data_train, labels_train)
|
||||||
|
predictions = model.predict(data_test)
|
||||||
|
|
||||||
def knn_regressor(data, outputs, test_size, n_neighbors = 5, weights = "uniform", algorithm = "auto", leaf_size = 30, p = 2, metric = "minkowski", metric_params = None, n_jobs = None):
|
return model, ClassificationMetrics(predictions, labels_test)
|
||||||
|
|
||||||
data_train, data_test, outputs_train, outputs_test = sklearn.model_selection.train_test_split(data, outputs, test_size=test_size, random_state=1)
|
def knn_regressor(data, outputs, test_size, n_neighbors = 5, weights = "uniform", algorithm = "auto", leaf_size = 30, p = 2, metric = "minkowski", metric_params = None, n_jobs = None):
|
||||||
model = sklearn.neighbors.KNeighborsRegressor(n_neighbors = n_neighbors, weights = weights, algorithm = algorithm, leaf_size = leaf_size, p = p, metric = metric, metric_params = metric_params, n_jobs = n_jobs)
|
|
||||||
model.fit(data_train, outputs_train)
|
|
||||||
predictions = model.predict(data_test)
|
|
||||||
|
|
||||||
return model, RegressionMetrics(predictions, outputs_test)
|
data_train, data_test, outputs_train, outputs_test = sklearn.model_selection.train_test_split(data, outputs, test_size=test_size, random_state=1)
|
||||||
|
model = sklearn.neighbors.KNeighborsRegressor(n_neighbors = n_neighbors, weights = weights, algorithm = algorithm, leaf_size = leaf_size, p = p, metric = metric, metric_params = metric_params, n_jobs = n_jobs)
|
||||||
|
model.fit(data_train, outputs_train)
|
||||||
|
predictions = model.predict(data_test)
|
||||||
|
|
||||||
|
return model, RegressionMetrics(predictions, outputs_test)
|
||||||
|
|
||||||
class NaiveBayes:
|
class NaiveBayes:
|
||||||
|
|
||||||
@@ -690,103 +697,4 @@ def random_forest_regressor(data, outputs, test_size, n_estimators="warn", crite
|
|||||||
kernel.fit(data_train, outputs_train)
|
kernel.fit(data_train, outputs_train)
|
||||||
predictions = kernel.predict(data_test)
|
predictions = kernel.predict(data_test)
|
||||||
|
|
||||||
return kernel, RegressionMetrics(predictions, outputs_test)
|
return kernel, RegressionMetrics(predictions, outputs_test)
|
||||||
|
|
||||||
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()
|
|
99
analysis-master/analysis-amd64/build/lib/analysis/glicko2.py
Normal file
99
analysis-master/analysis-amd64/build/lib/analysis/glicko2.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
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()
|
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.10-py3-none-any.whl
vendored
Normal file
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.10-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.10.tar.gz
vendored
Normal file
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.10.tar.gz
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.11.tar.gz
vendored
Normal file
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.11.tar.gz
vendored
Normal file
Binary file not shown.
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.9-py3-none-any.whl
vendored
Normal file
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.9-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.9.tar.gz
vendored
Normal file
BIN
analysis-master/analysis-amd64/dist/analysis-1.0.0.9.tar.gz
vendored
Normal file
Binary file not shown.
5
analysis-master/analysis-amd64/docker/Dockerfile
Normal file
5
analysis-master/analysis-amd64/docker/Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM python
|
||||||
|
WORKDIR ~/
|
||||||
|
COPY ./ ./
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
CMD ["bash"]
|
3
analysis-master/analysis-amd64/docker/start-docker.sh
Executable file
3
analysis-master/analysis-amd64/docker/start-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
cd ..
|
||||||
|
docker build -t tra-analysis-amd64-dev -f docker/Dockerfile .
|
||||||
|
docker run -it tra-analysis-amd64-dev
|
6
analysis-master/analysis-amd64/requirements.txt
Normal file
6
analysis-master/analysis-amd64/requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
numba
|
||||||
|
numpy
|
||||||
|
scipy
|
||||||
|
scikit-learn
|
||||||
|
six
|
||||||
|
matplotlib
|
@@ -1,8 +1,14 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
|
requirements = []
|
||||||
|
|
||||||
|
with open("requirements.txt", 'r') as file:
|
||||||
|
for line in file:
|
||||||
|
requirements.append(line)
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="analysis", # Replace with your own username
|
name="analysis",
|
||||||
version="1.0.0.009",
|
version="1.0.0.011",
|
||||||
author="The Titan Scouting Team",
|
author="The Titan Scouting Team",
|
||||||
author_email="titanscout2022@gmail.com",
|
author_email="titanscout2022@gmail.com",
|
||||||
description="analysis package developed by Titan Scouting for The Red Alliance",
|
description="analysis package developed by Titan Scouting for The Red Alliance",
|
||||||
@@ -10,14 +16,7 @@ setuptools.setup(
|
|||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url="https://github.com/titanscout2022/tr2022-strategy",
|
url="https://github.com/titanscout2022/tr2022-strategy",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
install_requires=[
|
install_requires=requirements,
|
||||||
"numba",
|
|
||||||
"numpy",
|
|
||||||
"scipy",
|
|
||||||
"scikit-learn",
|
|
||||||
"six",
|
|
||||||
"matplotlib"
|
|
||||||
],
|
|
||||||
license = "GNU General Public License v3.0",
|
license = "GNU General Public License v3.0",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
3
analysis-master/analysis-arm64/docker/start-docker.sh
Executable file
3
analysis-master/analysis-arm64/docker/start-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
cd ..
|
||||||
|
docker build -t tra-analysis-amd64-dev -f docker/Dockerfile .
|
||||||
|
docker run -it tra-analysis-amd64-dev
|
@@ -1 +0,0 @@
|
|||||||
python3 setup.py sdist bdist_wheel
|
|
BIN
analysis-master/dist/analysis-1.0.0.9.tar.gz
vendored
BIN
analysis-master/dist/analysis-1.0.0.9.tar.gz
vendored
Binary file not shown.
4
data analysis/requirements.txt
Normal file
4
data analysis/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
requests
|
||||||
|
pymongo
|
||||||
|
pandas
|
||||||
|
dnspython
|
@@ -3,12 +3,17 @@
|
|||||||
# Notes:
|
# Notes:
|
||||||
# setup:
|
# setup:
|
||||||
|
|
||||||
__version__ = "0.0.5.000"
|
__version__ = "0.0.5.002"
|
||||||
|
|
||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
|
0.0.5.002:
|
||||||
|
- made changes due to refactoring of analysis
|
||||||
|
0.0.5.001:
|
||||||
|
- text fixes
|
||||||
|
- removed matplotlib requirement
|
||||||
0.0.5.000:
|
0.0.5.000:
|
||||||
improved user interface
|
- improved user interface
|
||||||
0.0.4.002:
|
0.0.4.002:
|
||||||
- removed unessasary code
|
- removed unessasary code
|
||||||
0.0.4.001:
|
0.0.4.001:
|
||||||
@@ -84,7 +89,6 @@ __all__ = [
|
|||||||
from analysis import analysis as an
|
from analysis import analysis as an
|
||||||
import data as d
|
import data as d
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from os import system, name
|
from os import system, name
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
@@ -284,11 +288,11 @@ def metricsloop(tbakey, apikey, competition, timestamp): # listener based metric
|
|||||||
|
|
||||||
observations = {"red": 0.5, "blu": 0.5}
|
observations = {"red": 0.5, "blu": 0.5}
|
||||||
|
|
||||||
red_elo_delta = an.elo(red_elo["score"], blu_elo["score"], observations["red"], elo_N, elo_K) - red_elo["score"]
|
red_elo_delta = an.Metrics.elo(red_elo["score"], blu_elo["score"], observations["red"], elo_N, elo_K) - red_elo["score"]
|
||||||
blu_elo_delta = an.elo(blu_elo["score"], red_elo["score"], observations["blu"], elo_N, elo_K) - blu_elo["score"]
|
blu_elo_delta = an.Metrics.elo(blu_elo["score"], red_elo["score"], observations["blu"], elo_N, elo_K) - blu_elo["score"]
|
||||||
|
|
||||||
new_red_gl2_score, new_red_gl2_rd, new_red_gl2_vol = an.glicko2(red_gl2["score"], red_gl2["rd"], red_gl2["vol"], [blu_gl2["score"]], [blu_gl2["rd"]], [observations["red"], observations["blu"]])
|
new_red_gl2_score, new_red_gl2_rd, new_red_gl2_vol = an.Metrics.glicko2(red_gl2["score"], red_gl2["rd"], red_gl2["vol"], [blu_gl2["score"]], [blu_gl2["rd"]], [observations["red"], observations["blu"]])
|
||||||
new_blu_gl2_score, new_blu_gl2_rd, new_blu_gl2_vol = an.glicko2(blu_gl2["score"], blu_gl2["rd"], blu_gl2["vol"], [red_gl2["score"]], [red_gl2["rd"]], [observations["blu"], observations["red"]])
|
new_blu_gl2_score, new_blu_gl2_rd, new_blu_gl2_vol = an.Metrics.glicko2(blu_gl2["score"], blu_gl2["rd"], blu_gl2["vol"], [red_gl2["score"]], [red_gl2["rd"]], [observations["blu"], observations["red"]])
|
||||||
|
|
||||||
red_gl2_delta = {"score": new_red_gl2_score - red_gl2["score"], "rd": new_red_gl2_rd - red_gl2["rd"], "vol": new_red_gl2_vol - red_gl2["vol"]}
|
red_gl2_delta = {"score": new_red_gl2_score - red_gl2["score"], "rd": new_red_gl2_rd - red_gl2["rd"], "vol": new_red_gl2_vol - red_gl2["vol"]}
|
||||||
blu_gl2_delta = {"score": new_blu_gl2_score - blu_gl2["score"], "rd": new_blu_gl2_rd - blu_gl2["rd"], "vol": new_blu_gl2_vol - blu_gl2["vol"]}
|
blu_gl2_delta = {"score": new_blu_gl2_score - blu_gl2["score"], "rd": new_blu_gl2_rd - blu_gl2["rd"], "vol": new_blu_gl2_vol - blu_gl2["vol"]}
|
||||||
|
Reference in New Issue
Block a user