This commit is contained in:
ltcptgeneral 2019-03-21 15:59:47 -05:00
parent a20c427e77
commit 1538da4348
4 changed files with 37 additions and 26 deletions

View File

@ -1,3 +1,3 @@
29,63,35,37,26,51,35,58,30,61,45 29,63,35,37,26,51,35,58,30,61,45
26,62,45,37,42,29,59,44,40 35
35,63,62,18,56,65,42,77,82,63,76,50,47,69,57,65,85,70,38,67,89,74,71,67,70,71,95,77,45 63,61,45

1 29,63,35,37,26,51,35,58,30,61,45
2 26,62,45,37,42,29,59,44,40 35
3 35,63,62,18,56,65,42,77,82,63,76,50,47,69,57,65,85,70,38,67,89,74,71,67,70,71,95,77,45 63,61,45

View File

@ -1 +1,3 @@
2022 2451 16 2022
2451
16

1 2022 2451 16 2022
2 2451
3 16

View File

@ -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 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'))] #scores will be handled sperately 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
for i in files: for i in files:
data.append(analysis.load_csv(i)) data.append(analysis.load_csv(i))
@ -89,40 +89,40 @@ def titanservice():
for i in range(len(measure)): #unpacks into specific teams for i in range(len(measure)): #unpacks into specific teams
ofbest_curve = [None] #ofbest_curve = [None]
r2best_curve = [None] #r2best_curve = [None]
line = measure[i] line = measure[i]
#print(line) #print(line)
x = list(range(len(line))) #x = list(range(len(line)))
eqs, rmss, r2s, overfit = analysis.optimize_regression(x, line, 10, 1) #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) #print(eqs, rmss, r2s, overfit)
ofbest_curve.append(beqs) #ofbest_curve.append(beqs)
ofbest_curve.append(brmss) #ofbest_curve.append(brmss)
ofbest_curve.append(br2s) #ofbest_curve.append(br2s)
ofbest_curve.append(boverfit) #ofbest_curve.append(boverfit)
ofbest_curve.pop(0) #ofbest_curve.pop(0)
#print(ofbest_curve) #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(beqs)
r2best_curve.append(brmss) #r2best_curve.append(brmss)
r2best_curve.append(br2s) #r2best_curve.append(br2s)
r2best_curve.append(boverfit) #r2best_curve.append(boverfit)
r2best_curve.pop(0) #r2best_curve.pop(0)
#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)))
stats.append(list(measure_stats)) stats.append(list(measure_stats))
nishant = [] nishant = []
@ -209,6 +209,15 @@ def pulldata():
team_scores = [] team_scores = []
request_data_object = tba.req_team_matches(teams[i][0], 2019, "UDvKmPjPRfwwUdDX1JxbmkyecYBJhCtXeyVk9vmO2i7K0Zn4wqQPMfzuEINXJ7e5") request_data_object = tba.req_team_matches(teams[i][0], 2019, "UDvKmPjPRfwwUdDX1JxbmkyecYBJhCtXeyVk9vmO2i7K0Zn4wqQPMfzuEINXJ7e5")
json_data = request_data_object.json() json_data = request_data_object.json()
#print(json_data)
for i in range(len(json_data) - 1, -1, -1):
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) json_data = sorted(json_data, key=lambda k: k.get('actual_time', 0), reverse=False)
for j in range(len(json_data)): for j in range(len(json_data)):
if "frc" + teams[i][0] in json_data[j].get('alliances').get('blue').get('team_keys'): if "frc" + teams[i][0] in json_data[j].get('alliances').get('blue').get('team_keys'):
@ -217,12 +226,12 @@ def pulldata():
team_scores.append(json_data[j].get('alliances').get('red').get('score')) team_scores.append(json_data[j].get('alliances').get('red').get('score'))
scores.append(team_scores) scores.append(team_scores)
print(scores)
with open("data/scores.csv", "w+", newline = '') as file: with open("data/scores.csv", "w+", newline = '') as file:
writer = csv.writer(file, delimiter = ',') writer = csv.writer(file, delimiter = ',')
writer.writerows(scores) writer.writerows(scores)
def service(): def service():
while True: while True:
@ -231,17 +240,17 @@ def service():
start = time.time() start = time.time()
print("[OK]" + "time is: " + time.time()) #print("[OK]" + "time is: " + time.time())
print("[OK] starting calculations") print("[OK] starting calculations")
fucked = False fucked = False
for i in range(0, 5): for i in range(0, 5):
try: #try:
titanservice() titanservice()
break break
except: #except:
if (i != 4): if (i != 4):
print("[WARNING] failed, trying " + str(5 - i - 1) + " more times") print("[WARNING] failed, trying " + str(5 - i - 1) + " more times")
else: else: