mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-07 07:27:20 +00:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
50c064ffa4 | ||
|
1b0a9967c8 | ||
|
2605f7c29f | ||
|
6f5a3edd88 | ||
|
457146b0e4 | ||
|
f7fd8ffcf9 | ||
|
77bc792426 | ||
|
39146cc555 | ||
|
04141bbec8 | ||
|
40e5899972 | ||
|
025c7f9b3c | ||
|
2daa09c040 | ||
|
68d27a6302 | ||
|
7fc18b7c35 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -18,4 +18,5 @@ data analysis/arthur_pull.ipynb
|
||||
data analysis/keys.txt
|
||||
data analysis/check_for_new_matches.ipynb
|
||||
data analysis/test.ipynb
|
||||
data analysis/visualize_pit.ipynb
|
||||
data analysis/visualize_pit.ipynb
|
||||
data analysis/config/keys.config
|
@@ -1,6 +1,6 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: analysis
|
||||
Version: 1.0.0.7
|
||||
Version: 1.0.0.8
|
||||
Summary: analysis package developed by Titan Scouting for The Red Alliance
|
||||
Home-page: https://github.com/titanscout2022/tr2022-strategy
|
||||
Author: The Titan Scouting Team
|
||||
|
@@ -8,4 +8,5 @@ analysis/visualization.py
|
||||
analysis.egg-info/PKG-INFO
|
||||
analysis.egg-info/SOURCES.txt
|
||||
analysis.egg-info/dependency_links.txt
|
||||
analysis.egg-info/requires.txt
|
||||
analysis.egg-info/top_level.txt
|
6
analysis-master/analysis.egg-info/requires.txt
Normal file
6
analysis-master/analysis.egg-info/requires.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
numba
|
||||
numpy
|
||||
scipy
|
||||
scikit-learn
|
||||
six
|
||||
matplotlib
|
@@ -7,10 +7,12 @@
|
||||
# current benchmark of optimization: 1.33 times faster
|
||||
# setup:
|
||||
|
||||
__version__ = "1.1.13.005"
|
||||
__version__ = "1.1.13.006"
|
||||
|
||||
# changelog should be viewed using print(analysis.__changelog__)
|
||||
__changelog__ = """changelog:
|
||||
1.1.13.006:
|
||||
- cleaned up imports
|
||||
1.1.13.005:
|
||||
- cleaned up package
|
||||
1.1.13.004:
|
||||
@@ -283,10 +285,7 @@ import scipy
|
||||
from scipy import *
|
||||
import sklearn
|
||||
from sklearn import *
|
||||
try:
|
||||
from analysis import trueskill as Trueskill
|
||||
except:
|
||||
import trueskill as Trueskill
|
||||
from analysis import trueskill as Trueskill
|
||||
|
||||
class error(ValueError):
|
||||
pass
|
||||
|
@@ -5,19 +5,22 @@
|
||||
# this module is cuda-optimized and vectorized (except for one small part)
|
||||
# setup:
|
||||
|
||||
__version__ = "1.0.0.003"
|
||||
__version__ = "1.0.0.004"
|
||||
|
||||
# changelog should be viewed using print(analysis.regression.__changelog__)
|
||||
__changelog__ = """
|
||||
1.0.0.003:
|
||||
- bug fixes
|
||||
1.0.0.002:
|
||||
-Added more parameters to log, exponential, polynomial
|
||||
-Added SigmoidalRegKernelArthur, because Arthur apparently needs
|
||||
to train the scaling and shifting of sigmoids
|
||||
1.0.0.001:
|
||||
-initial release, with linear, log, exponential, polynomial, and sigmoid kernels
|
||||
-already vectorized (except for polynomial generation) and CUDA-optimized
|
||||
1.0.0.004:
|
||||
- bug fixes
|
||||
- fixed changelog
|
||||
1.0.0.003:
|
||||
- bug fixes
|
||||
1.0.0.002:
|
||||
-Added more parameters to log, exponential, polynomial
|
||||
-Added SigmoidalRegKernelArthur, because Arthur apparently needs
|
||||
to train the scaling and shifting of sigmoids
|
||||
1.0.0.001:
|
||||
-initial release, with linear, log, exponential, polynomial, and sigmoid kernels
|
||||
-already vectorized (except for polynomial generation) and CUDA-optimized
|
||||
"""
|
||||
|
||||
__author__ = (
|
||||
@@ -40,6 +43,8 @@ __all__ = [
|
||||
'CustomTrain'
|
||||
]
|
||||
|
||||
import torch
|
||||
|
||||
global device
|
||||
|
||||
device = "cuda:0" if torch.torch.cuda.is_available() else "cpu"
|
||||
|
0
analysis-master/build.sh
Executable file → Normal file
0
analysis-master/build.sh
Executable file → Normal file
@@ -7,10 +7,20 @@
|
||||
# current benchmark of optimization: 1.33 times faster
|
||||
# setup:
|
||||
|
||||
__version__ = "1.1.13.001"
|
||||
__version__ = "1.1.13.006"
|
||||
|
||||
# changelog should be viewed using print(analysis.__changelog__)
|
||||
__changelog__ = """changelog:
|
||||
1.1.13.006:
|
||||
- cleaned up imports
|
||||
1.1.13.005:
|
||||
- cleaned up package
|
||||
1.1.13.004:
|
||||
- small fixes to regression to improve performance
|
||||
1.1.13.003:
|
||||
- filtered nans from regression
|
||||
1.1.13.002:
|
||||
- removed torch requirement, and moved Regression back to regression.py
|
||||
1.1.13.001:
|
||||
- bug fix with linear regression not returning a proper value
|
||||
- cleaned up regression
|
||||
@@ -239,7 +249,6 @@ __author__ = (
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'_init_device',
|
||||
'load_csv',
|
||||
'basic_stats',
|
||||
'z_score',
|
||||
@@ -260,7 +269,6 @@ __all__ = [
|
||||
'SVM',
|
||||
'random_forest_classifier',
|
||||
'random_forest_regressor',
|
||||
'Regression',
|
||||
'Glicko2',
|
||||
# all statistics functions left out due to integration in other functions
|
||||
]
|
||||
@@ -273,15 +281,11 @@ import csv
|
||||
import numba
|
||||
from numba import jit
|
||||
import numpy as np
|
||||
import math
|
||||
import scipy
|
||||
from scipy import *
|
||||
import sklearn
|
||||
from sklearn import *
|
||||
try:
|
||||
from analysis import trueskill as Trueskill
|
||||
except:
|
||||
import trueskill as Trueskill
|
||||
from analysis import trueskill as Trueskill
|
||||
|
||||
class error(ValueError):
|
||||
pass
|
||||
@@ -344,15 +348,15 @@ def histo_analysis(hist_data):
|
||||
|
||||
def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
|
||||
regressions = []
|
||||
|
||||
if 'lin' in args: # formula: ax + b
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
|
||||
def func(x, a, b):
|
||||
|
||||
return a * x + b
|
||||
@@ -369,9 +373,6 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
|
||||
def func(x, a, b, c, d):
|
||||
|
||||
return a * np.log(b*(x + c)) + d
|
||||
@@ -386,10 +387,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
if 'exp' in args: # formula: a e ^ (b(x + c)) + d
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
try:
|
||||
|
||||
def func(x, a, b, c, d):
|
||||
|
||||
@@ -405,8 +403,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
if 'ply' in args: # formula: a + bx^1 + cx^2 + dx^3 + ...
|
||||
|
||||
inputs = [inputs]
|
||||
outputs = [outputs]
|
||||
inputs = np.array([inputs])
|
||||
outputs = np.array([outputs])
|
||||
|
||||
plys = []
|
||||
limit = len(outputs[0])
|
||||
@@ -428,10 +426,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
if 'sig' in args: # formula: a tanh (b(x + c)) + d
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
try:
|
||||
|
||||
def func(x, a, b, c, d):
|
||||
|
||||
|
@@ -5,19 +5,22 @@
|
||||
# this module is cuda-optimized and vectorized (except for one small part)
|
||||
# setup:
|
||||
|
||||
__version__ = "1.0.0.003"
|
||||
__version__ = "1.0.0.004"
|
||||
|
||||
# changelog should be viewed using print(analysis.regression.__changelog__)
|
||||
__changelog__ = """
|
||||
1.0.0.003:
|
||||
- bug fixes
|
||||
1.0.0.002:
|
||||
-Added more parameters to log, exponential, polynomial
|
||||
-Added SigmoidalRegKernelArthur, because Arthur apparently needs
|
||||
to train the scaling and shifting of sigmoids
|
||||
1.0.0.001:
|
||||
-initial release, with linear, log, exponential, polynomial, and sigmoid kernels
|
||||
-already vectorized (except for polynomial generation) and CUDA-optimized
|
||||
1.0.0.004:
|
||||
- bug fixes
|
||||
- fixed changelog
|
||||
1.0.0.003:
|
||||
- bug fixes
|
||||
1.0.0.002:
|
||||
-Added more parameters to log, exponential, polynomial
|
||||
-Added SigmoidalRegKernelArthur, because Arthur apparently needs
|
||||
to train the scaling and shifting of sigmoids
|
||||
1.0.0.001:
|
||||
-initial release, with linear, log, exponential, polynomial, and sigmoid kernels
|
||||
-already vectorized (except for polynomial generation) and CUDA-optimized
|
||||
"""
|
||||
|
||||
__author__ = (
|
||||
@@ -40,6 +43,8 @@ __all__ = [
|
||||
'CustomTrain'
|
||||
]
|
||||
|
||||
import torch
|
||||
|
||||
global device
|
||||
|
||||
device = "cuda:0" if torch.torch.cuda.is_available() else "cpu"
|
||||
|
Binary file not shown.
BIN
analysis-master/dist/analysis-1.0.0.7.tar.gz
vendored
BIN
analysis-master/dist/analysis-1.0.0.7.tar.gz
vendored
Binary file not shown.
BIN
analysis-master/dist/analysis-1.0.0.8-py3-none-any.whl
vendored
Normal file
BIN
analysis-master/dist/analysis-1.0.0.8-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
analysis-master/dist/analysis-1.0.0.8.tar.gz
vendored
Normal file
BIN
analysis-master/dist/analysis-1.0.0.8.tar.gz
vendored
Normal file
Binary file not shown.
@@ -2,7 +2,7 @@ import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
name="analysis", # Replace with your own username
|
||||
version="1.0.0.007",
|
||||
version="1.0.0.008",
|
||||
author="The Titan Scouting Team",
|
||||
author_email="titanscout2022@gmail.com",
|
||||
description="analysis package developed by Titan Scouting for The Red Alliance",
|
||||
@@ -10,6 +10,14 @@ setuptools.setup(
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/titanscout2022/tr2022-strategy",
|
||||
packages=setuptools.find_packages(),
|
||||
install_requires=[
|
||||
"numba",
|
||||
"numpy",
|
||||
"scipy",
|
||||
"scikit-learn",
|
||||
"six",
|
||||
"matplotlib"
|
||||
],
|
||||
license = "GNU General Public License v3.0",
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3",
|
||||
|
Binary file not shown.
1
data analysis/config/competition.config
Normal file
1
data analysis/config/competition.config
Normal file
@@ -0,0 +1 @@
|
||||
2020ilch
|
0
data analysis/config/database.config
Normal file
0
data analysis/config/database.config
Normal file
@@ -1,4 +1,3 @@
|
||||
2020ilch
|
||||
balls-blocked,basic_stats,historical_analysis,regression_linear,regression_logarithmic,regression_exponential,regression_polynomial,regression_sigmoidal
|
||||
balls-collected,basic_stats,historical_analysis,regression_linear,regression_logarithmic,regression_exponential,regression_polynomial,regression_sigmoidal
|
||||
balls-lower-teleop,basic_stats,historical_analysis,regression_linear,regression_logarithmic,regression_exponential,regression_polynomial,regression_sigmoidal
|
59
data analysis/get_team_rankings.py
Normal file
59
data analysis/get_team_rankings.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import data as d
|
||||
from analysis import analysis as an
|
||||
import pymongo
|
||||
import operator
|
||||
|
||||
def load_config(file):
|
||||
config_vector = {}
|
||||
file = an.load_csv(file)
|
||||
for line in file[1:]:
|
||||
config_vector[line[0]] = line[1:]
|
||||
|
||||
return (file[0][0], config_vector)
|
||||
|
||||
def get_metrics_processed_formatted(apikey, competition):
|
||||
client = pymongo.MongoClient(apikey)
|
||||
db = client.data_scouting
|
||||
mdata = db.teamlist
|
||||
x=mdata.find_one({"competition":competition})
|
||||
out = {}
|
||||
for i in x:
|
||||
try:
|
||||
out[int(i)] = d.get_team_metrics_data(apikey, competition, int(i))
|
||||
except:
|
||||
pass
|
||||
return out
|
||||
|
||||
def main():
|
||||
|
||||
apikey = an.load_csv("keys.txt")[0][0]
|
||||
tbakey = an.load_csv("keys.txt")[1][0]
|
||||
|
||||
competition, config = load_config("config.csv")
|
||||
|
||||
metrics = get_metrics_processed_formatted(apikey, competition)
|
||||
|
||||
elo = {}
|
||||
gl2 = {}
|
||||
|
||||
for team in metrics:
|
||||
|
||||
elo[team] = metrics[team]["metrics"]["elo"]["score"]
|
||||
gl2[team] = metrics[team]["metrics"]["gl2"]["score"]
|
||||
|
||||
elo = {k: v for k, v in sorted(elo.items(), key=lambda item: item[1])}
|
||||
gl2 = {k: v for k, v in sorted(gl2.items(), key=lambda item: item[1])}
|
||||
|
||||
for team in elo:
|
||||
|
||||
print("teams sorted by elo:")
|
||||
print("" + str(team) + " | " + str(elo[team]))
|
||||
|
||||
print("*"*25)
|
||||
|
||||
for team in gl2:
|
||||
|
||||
print("teams sorted by glicko2:")
|
||||
print("" + str(team) + " | " + str(gl2[team]))
|
||||
|
||||
main()
|
@@ -3,10 +3,12 @@
|
||||
# Notes:
|
||||
# setup:
|
||||
|
||||
__version__ = "0.0.4.002"
|
||||
__version__ = "0.0.5.000"
|
||||
|
||||
# changelog should be viewed using print(analysis.__changelog__)
|
||||
__changelog__ = """changelog:
|
||||
0.0.5.000:
|
||||
improved user interface
|
||||
0.0.4.002:
|
||||
- removed unessasary code
|
||||
0.0.4.001:
|
||||
@@ -83,6 +85,8 @@ from analysis import analysis as an
|
||||
import data as d
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from os import system, name
|
||||
from pathlib import Path
|
||||
import time
|
||||
import warnings
|
||||
|
||||
@@ -91,16 +95,16 @@ def main():
|
||||
while(True):
|
||||
|
||||
current_time = time.time()
|
||||
print("time: " + str(current_time))
|
||||
print("[OK] time: " + str(current_time))
|
||||
|
||||
print(" loading config")
|
||||
competition, config = load_config("config.csv")
|
||||
print(" config loaded")
|
||||
start = time.time()
|
||||
config = load_config(Path("config/stats.config"))
|
||||
competition = an.load_csv(Path("config/competition.config"))[0][0]
|
||||
print("[OK] configs loaded")
|
||||
|
||||
print(" loading database keys")
|
||||
apikey = an.load_csv("keys.txt")[0][0]
|
||||
tbakey = an.load_csv("keys.txt")[1][0]
|
||||
print(" loaded keys")
|
||||
apikey = an.load_csv(Path("config/keys.config"))[0][0]
|
||||
tbakey = an.load_csv(Path("config/keys.config"))[1][0]
|
||||
print("[OK] loaded keys")
|
||||
|
||||
previous_time = d.get_analysis_flags(apikey, "latest_update")
|
||||
|
||||
@@ -113,38 +117,55 @@ def main():
|
||||
|
||||
previous_time = previous_time["latest_update"]
|
||||
|
||||
print(" analysis backtimed to: " + str(previous_time))
|
||||
print("[OK] analysis backtimed to: " + str(previous_time))
|
||||
|
||||
print(" loading data")
|
||||
print("[OK] loading data")
|
||||
start = time.time()
|
||||
data = d.get_match_data_formatted(apikey, competition)
|
||||
pit_data = d.pit = d.get_pit_data_formatted(apikey, competition)
|
||||
print(" loaded data")
|
||||
print("[OK] loaded data in " + str(time.time() - start) + " seconds")
|
||||
|
||||
print(" running tests")
|
||||
print("[OK] running tests")
|
||||
start = time.time()
|
||||
results = simpleloop(data, config)
|
||||
print(" finished tests")
|
||||
print("[OK] finished tests in " + str(time.time() - start) + " seconds")
|
||||
|
||||
print(" running metrics")
|
||||
print("[OK] running metrics")
|
||||
start = time.time()
|
||||
metricsloop(tbakey, apikey, competition, previous_time)
|
||||
print(" finished metrics")
|
||||
print("[OK] finished metrics in " + str(time.time() - start) + " seconds")
|
||||
|
||||
print(" running pit analysis")
|
||||
print("[OK] running pit analysis")
|
||||
start = time.time()
|
||||
pit = pitloop(pit_data, config)
|
||||
print(" finished pit analysis")
|
||||
print("[OK] finished pit analysis in " + str(time.time() - start) + " seconds")
|
||||
|
||||
d.set_analysis_flags(apikey, "latest_update", {"latest_update":current_time})
|
||||
|
||||
print(" pushing to database")
|
||||
print("[OK] pushing to database")
|
||||
start = time.time()
|
||||
push_to_database(apikey, competition, results, pit)
|
||||
print(" pushed to database")
|
||||
print("[OK] pushed to database in " + str(time.time() - start) + " seconds")
|
||||
|
||||
clear()
|
||||
|
||||
def clear():
|
||||
|
||||
# for windows
|
||||
if name == 'nt':
|
||||
_ = system('cls')
|
||||
|
||||
# for mac and linux(here, os.name is 'posix')
|
||||
else:
|
||||
_ = system('clear')
|
||||
|
||||
def load_config(file):
|
||||
config_vector = {}
|
||||
file = an.load_csv(file)
|
||||
for line in file[1:]:
|
||||
for line in file:
|
||||
config_vector[line[0]] = line[1:]
|
||||
|
||||
return (file[0][0], config_vector)
|
||||
return config_vector
|
||||
|
||||
def simpleloop(data, tests): # expects 3D array with [Team][Variable][Match]
|
||||
|
||||
@@ -208,8 +229,6 @@ def metricsloop(tbakey, apikey, competition, timestamp): # listener based metric
|
||||
|
||||
matches = d.pull_new_tba_matches(tbakey, competition, timestamp)
|
||||
|
||||
return_vector = {}
|
||||
|
||||
red = {}
|
||||
blu = {}
|
||||
|
||||
|
Reference in New Issue
Block a user