mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 06:54:44 +00:00
working
This commit is contained in:
parent
1538da4348
commit
7642c39197
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,1.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
1.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
1.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,5.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,1.0
|
||||
1.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,4.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
0.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
13.0
|
||||
0.0,0.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
10.0
|
||||
0.0,7.0
|
||||
7.0
|
|
@ -1,3 +0,0 @@
|
||||
1.0
|
||||
0.0,7.0
|
||||
0.0
|
|
@ -1,3 +0,0 @@
|
||||
match-23
|
||||
match-18,match-3
|
||||
match-18
|
|
@ -1,3 +0,0 @@
|
||||
yeeee
|
||||
,si papa
|
||||
nine
|
|
@ -1,3 +0,0 @@
|
||||
Quantitative
|
||||
Quantitative,Quantitative
|
||||
Quantitative
|
|
@ -1,3 +0,0 @@
|
||||
team-2022
|
||||
team-16,team-16
|
||||
team-2451
|
|
@ -67,7 +67,7 @@ def titanservice():
|
||||
file_list = glob.glob(source_dir + '/*.csv') #supposedly sorts by alphabetical order, skips reading teams.csv because of redundancy
|
||||
data = []
|
||||
files = [fn for fn in glob.glob('data/*.csv')
|
||||
if not (os.path.basename(fn).startswith('teams') or os.path.basename(fn).startswith('match') or os.path.basename(fn).startswith('notes') or os.path.basename(fn).startswith('observationType') or os.path.basename(fn).startswith('teamDBRef') )] #scores will be handled sperately
|
||||
if not (os.path.basename(fn).startswith('teams'))] #scores will be handled sperately
|
||||
|
||||
for i in files:
|
||||
data.append(analysis.load_csv(i))
|
||||
@ -89,40 +89,40 @@ def titanservice():
|
||||
|
||||
for i in range(len(measure)): #unpacks into specific teams
|
||||
|
||||
#ofbest_curve = [None]
|
||||
#r2best_curve = [None]
|
||||
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)
|
||||
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")
|
||||
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)
|
||||
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")
|
||||
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)
|
||||
r2best_curve.append(beqs)
|
||||
r2best_curve.append(brmss)
|
||||
r2best_curve.append(br2s)
|
||||
r2best_curve.append(boverfit)
|
||||
r2best_curve.pop(0)
|
||||
|
||||
#print(r2best_curve)
|
||||
|
||||
|
||||
measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)) + list(analysis.histo_analysis(line, 1, -3, 3)))
|
||||
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))
|
||||
nishant = []
|
||||
@ -174,18 +174,9 @@ def titanservice():
|
||||
json_out = {}
|
||||
score_out = {}
|
||||
|
||||
#print(stats)
|
||||
|
||||
#print(stats[0])
|
||||
|
||||
#for i in range(len(teams)):
|
||||
# json_out[str(teams[i][0])] = (stats[0][i])
|
||||
|
||||
for i in range(len(teams)):
|
||||
score_out[str(teams[i][0])] = (nishant[i])
|
||||
|
||||
#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])
|
||||
@ -198,26 +189,18 @@ def titanservice():
|
||||
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():
|
||||
|
||||
teams = analysis.load_csv('data/teams.csv')
|
||||
scores = []
|
||||
for i in range(len(teams)):
|
||||
team_scores = []
|
||||
#print(teams[i][0])
|
||||
request_data_object = tba.req_team_matches(teams[i][0], 2019, "UDvKmPjPRfwwUdDX1JxbmkyecYBJhCtXeyVk9vmO2i7K0Zn4wqQPMfzuEINXJ7e5")
|
||||
json_data = request_data_object.json()
|
||||
#print(json_data)
|
||||
|
||||
for i in range(len(json_data) - 1, -1, -1):
|
||||
#for i in json_data:
|
||||
|
||||
# if i
|
||||
|
||||
if json_data[i].get('winning_alliance') == None or json_data[i].get('winning_alliance') == [] or json_data[i].get('winning_alliance') == "":
|
||||
print(json_data[i])
|
||||
json_data.remove(json_data[i])
|
||||
|
||||
#print(json_data)
|
||||
json_data = sorted(json_data, key=lambda k: k.get('actual_time', 0), reverse=False)
|
||||
for j in range(len(json_data)):
|
||||
if "frc" + teams[i][0] in json_data[j].get('alliances').get('blue').get('team_keys'):
|
||||
@ -226,8 +209,6 @@ def pulldata():
|
||||
team_scores.append(json_data[j].get('alliances').get('red').get('score'))
|
||||
scores.append(team_scores)
|
||||
|
||||
print(scores)
|
||||
|
||||
with open("data/scores.csv", "w+", newline = '') as file:
|
||||
writer = csv.writer(file, delimiter = ',')
|
||||
writer.writerows(scores)
|
||||
@ -240,17 +221,15 @@ def service():
|
||||
|
||||
start = time.time()
|
||||
|
||||
#print("[OK]" + "time is: " + time.time())
|
||||
|
||||
print("[OK] starting calculations")
|
||||
|
||||
fucked = False
|
||||
|
||||
for i in range(0, 5):
|
||||
#try:
|
||||
try:
|
||||
titanservice()
|
||||
break
|
||||
#except:
|
||||
except:
|
||||
if (i != 4):
|
||||
print("[WARNING] failed, trying " + str(5 - i - 1) + " more times")
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user