mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-27 01:59:08 +00:00
lotta bug fixes
This commit is contained in:
parent
035712c1ea
commit
98a2519f42
Binary file not shown.
Binary file not shown.
@ -758,7 +758,7 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
|
|||||||
x_test = []
|
x_test = []
|
||||||
y_test = []
|
y_test = []
|
||||||
|
|
||||||
for i in range (0, math.floor(len(x) * 0.4), 1):
|
for i in range (0, math.floor(len(x) * 0.5), 1):
|
||||||
index = random.randint(0, len(x) - 1)
|
index = random.randint(0, len(x) - 1)
|
||||||
|
|
||||||
x_test.append(x[index])
|
x_test.append(x[index])
|
||||||
|
1
data analysis/data/scores.csv
Normal file
1
data analysis/data/scores.csv
Normal file
@ -0,0 +1 @@
|
|||||||
|
2022, 21, 23, 39, 50, 89, 97, 191, 213, 233, 236, 272, 289, 308, 310, 314, 317, 329, 355, 428, 436
2011, 1, 25, 34, 106, 112, 132, 146, 167, 184, 223, 256, 267, 304, 337, 339, 370, 411, 460, 485, 494
1101, 7, 11, 55, 81, 92, 144, 151, 157, 165, 174, 177, 220, 241, 312, 320, 341, 343, 347, 419, 473
821374, 6, 9, 11, 28, 31, 194, 200, 201, 246, 298, 340, 351, 355, 364, 388, 395, 414, 422, 429, 442
5, 33, 73, 102, 103, 137, 183, 200, 212, 218, 242, 249, 264, 294, 302, 310, 378, 400, 408, 457, 473
|
|
@ -41,6 +41,7 @@ import firebase_admin
|
|||||||
from firebase_admin import credentials
|
from firebase_admin import credentials
|
||||||
from firebase_admin import firestore
|
from firebase_admin import firestore
|
||||||
import analysis
|
import analysis
|
||||||
|
import titanlearn
|
||||||
import visualization
|
import visualization
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -59,7 +60,7 @@ def titanservice():
|
|||||||
file_list = glob.glob(source_dir + '/*.csv') #supposedly sorts by alphabetical order, skips reading teams.csv because of redundancy
|
file_list = glob.glob(source_dir + '/*.csv') #supposedly sorts by alphabetical order, skips reading teams.csv because of redundancy
|
||||||
data = []
|
data = []
|
||||||
files = [fn for fn in glob.glob('data/*.csv')
|
files = [fn for fn in glob.glob('data/*.csv')
|
||||||
if not os.path.basename(fn).startswith('teams')]
|
if not (os.path.basename(fn).startswith('teams'))] #scores will be handled sperately
|
||||||
|
|
||||||
for i in files:
|
for i in files:
|
||||||
data.append(analysis.load_csv(i))
|
data.append(analysis.load_csv(i))
|
||||||
@ -67,6 +68,7 @@ def titanservice():
|
|||||||
stats = []
|
stats = []
|
||||||
measure_stats = []
|
measure_stats = []
|
||||||
teams = analysis.load_csv("data/teams.csv")
|
teams = analysis.load_csv("data/teams.csv")
|
||||||
|
scores = analysis.load_csv("data/scores.csv")
|
||||||
|
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
|
||||||
@ -112,18 +114,81 @@ def titanservice():
|
|||||||
|
|
||||||
#print(r2best_curve)
|
#print(r2best_curve)
|
||||||
|
|
||||||
measure_stats.append(teams[i] + ["|"] + list(analysis.basic_stats(line, 0, 0)) + ["|"] + list(analysis.histo_analysis(line, 1, -3, 3)) + ["|"] + ofbest_curve + ["|"] + r2best_curve)
|
|
||||||
|
measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)) + list(analysis.histo_analysis(line, 1, -3, 3)) + ofbest_curve + r2best_curve)
|
||||||
|
|
||||||
stats.append(list(measure_stats))
|
stats.append(list(measure_stats))
|
||||||
|
nishant = []
|
||||||
|
for i in range(len(scores)):
|
||||||
|
|
||||||
|
ofbest_curve = [None]
|
||||||
|
r2best_curve = [None]
|
||||||
|
|
||||||
|
line = measure[i]
|
||||||
|
|
||||||
|
#print(line)
|
||||||
|
|
||||||
|
x = list(range(len(line)))
|
||||||
|
eqs, rmss, r2s, overfit = analysis.optimize_regression(x, line, 10, 1)
|
||||||
|
|
||||||
|
beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "min_overfit")
|
||||||
|
|
||||||
|
#print(eqs, rmss, r2s, overfit)
|
||||||
|
|
||||||
|
ofbest_curve.append(beqs)
|
||||||
|
ofbest_curve.append(brmss)
|
||||||
|
ofbest_curve.append(br2s)
|
||||||
|
ofbest_curve.append(boverfit)
|
||||||
|
ofbest_curve.pop(0)
|
||||||
|
|
||||||
|
#print(ofbest_curve)
|
||||||
|
|
||||||
|
beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "max_r2s")
|
||||||
|
|
||||||
|
r2best_curve.append(beqs)
|
||||||
|
r2best_curve.append(brmss)
|
||||||
|
r2best_curve.append(br2s)
|
||||||
|
r2best_curve.append(boverfit)
|
||||||
|
r2best_curve.pop(0)
|
||||||
|
|
||||||
|
#print(r2best_curve)
|
||||||
|
|
||||||
|
z = len(scores[0]) + 1
|
||||||
|
nis_num = []
|
||||||
|
|
||||||
|
nis_num.append(eval(str(ofbest_curve[0])))
|
||||||
|
nis_num.append(eval(str(r2best_curve[0])))
|
||||||
|
|
||||||
|
nis_num.append((eval(ofbest_curve[0]) + eval(r2best_curve[0])) / 2)
|
||||||
|
|
||||||
|
nishant.append(teams[i] + nis_num)
|
||||||
|
|
||||||
json_out = {}
|
json_out = {}
|
||||||
|
score_out = {}
|
||||||
|
|
||||||
for i in range(len(stats)):
|
#print(stats)
|
||||||
json_out[files[i]]=str(stats[i])
|
|
||||||
|
|
||||||
#print(json_out)
|
for i in range(len(teams)):
|
||||||
|
json_out[str(teams[i][0])] = (stats[0][i])
|
||||||
|
|
||||||
db.collection(u'stats').document(u'stats-noNN').set(json_out)
|
for i in range(len(teams)):
|
||||||
|
score_out[str(teams[i][0])] = (nishant[i])
|
||||||
|
|
||||||
|
print(json_out)
|
||||||
|
|
||||||
|
#print(json_out.get('5'))
|
||||||
|
|
||||||
|
location = db.collection(u'stats').document(u'stats-noNN')
|
||||||
|
for i in range(len(teams)):
|
||||||
|
general_general_stats = location.collection(teams[i][0])
|
||||||
|
for j in range(len(files)):
|
||||||
|
general_general_stats.document(files[j]).set({'stats':json_out.get(teams[i][0])})
|
||||||
|
|
||||||
|
for i in range(len(teams)):
|
||||||
|
nnum = location.collection(teams[i][0]).document(u'nishant_number').set({'nishant':score_out.get(teams[i][0])})
|
||||||
|
|
||||||
|
#general_general_stats.collection().document('stats').set()
|
||||||
|
#db.collection(u'stats').document(u'stats-noNN').set(score_out)
|
||||||
|
|
||||||
def pulldata():
|
def pulldata():
|
||||||
#TODO
|
#TODO
|
||||||
@ -173,3 +238,4 @@ firebase_admin.initialize_app(cred)
|
|||||||
db = firestore.client()
|
db = firestore.client()
|
||||||
|
|
||||||
service() #finally we write something that isn't a function definition
|
service() #finally we write something that isn't a function definition
|
||||||
|
#titanservice()
|
||||||
|
@ -198,4 +198,4 @@ def retyuoipufdyu():
|
|||||||
model = linear_nn(8, 100, 1, 20, act_fn = "relu")
|
model = linear_nn(8, 100, 1, 20, act_fn = "relu")
|
||||||
print(model)
|
print(model)
|
||||||
return train_sgd_simple(model,"regression", data, ground, learnrate=1e-4, iters=1000)
|
return train_sgd_simple(model,"regression", data, ground, learnrate=1e-4, iters=1000)
|
||||||
retyuoipufdyu()
|
#retyuoipufdyu()
|
||||||
|
Loading…
Reference in New Issue
Block a user