mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 06:54:44 +00:00
superscript.py - v 1.0.4.001
changelog: - grammar fixes
This commit is contained in:
parent
2b1dd3ed9b
commit
9b9d6bcd23
BIN
data analysis/__pycache__/superscript.cpython-37.pyc
Normal file
BIN
data analysis/__pycache__/superscript.cpython-37.pyc
Normal file
Binary file not shown.
@ -1,11 +1,13 @@
|
||||
#Titan Robotics Team 2022: Data Analysis Script
|
||||
#Titan Robotics Team 2022: Super Script
|
||||
#Written by Arthur Lu & Jacob Levine
|
||||
#Notes:
|
||||
#setup:
|
||||
|
||||
__version__ = "1.0.4.000"
|
||||
__version__ = "1.0.4.001"
|
||||
|
||||
__changelog__ = """changelog:
|
||||
1.0.4.001:
|
||||
- grammar fixes
|
||||
1.0.4.000:
|
||||
- actually pushes to firebase
|
||||
1.0.3.001:
|
||||
@ -37,82 +39,84 @@ import os
|
||||
import glob
|
||||
import numpy as np
|
||||
|
||||
# Use a service account
|
||||
cred = credentials.Certificate('keys/firebasekey.json')
|
||||
firebase_admin.initialize_app(cred)
|
||||
def titanservice():
|
||||
|
||||
# Use a service account
|
||||
cred = credentials.Certificate('keys/firebasekey.json')
|
||||
firebase_admin.initialize_app(cred)
|
||||
|
||||
db = firestore.client()
|
||||
db = firestore.client()
|
||||
|
||||
#get all the data
|
||||
#get all the data
|
||||
|
||||
analysis.generate_data("data/bdata.csv", 100, 5, -10, 10)
|
||||
analysis.generate_data("data/bdata.csv", 100, 5, -10, 10)
|
||||
|
||||
source_dir = 'data'
|
||||
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')]
|
||||
source_dir = 'data'
|
||||
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')]
|
||||
|
||||
#for file_path in file_list:
|
||||
# if not os.path.basename(file_list).startswith("teams")
|
||||
# data.append(analysis.load_csv(file_path))
|
||||
#for file_path in file_list:
|
||||
# if not os.path.basename(file_list).startswith("teams")
|
||||
# data.append(analysis.load_csv(file_path))
|
||||
|
||||
for i in files:
|
||||
data.append(analysis.load_csv(i))
|
||||
for i in files:
|
||||
data.append(analysis.load_csv(i))
|
||||
|
||||
stats = []
|
||||
measure_stats = []
|
||||
teams = analysis.load_csv("data/teams.csv")
|
||||
stats = []
|
||||
measure_stats = []
|
||||
teams = analysis.load_csv("data/teams.csv")
|
||||
|
||||
#assumes that team number is in the first column, and that the order of teams is the same across all files
|
||||
#unhelpful comment
|
||||
for measure in data: #unpacks 3d array into 2ds
|
||||
#assumes that team number is in the first column, and that the order of teams is the same across all files
|
||||
#unhelpful comment
|
||||
for measure in data: #unpacks 3d array into 2ds
|
||||
|
||||
measure_stats = []
|
||||
measure_stats = []
|
||||
|
||||
for i in range(len(measure)): #unpacks into specific teams
|
||||
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]
|
||||
line = measure[i]
|
||||
|
||||
#print(line)
|
||||
#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)
|
||||
#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)
|
||||
#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)) + ["|"] + ofbest_curve + ["|"] + 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)
|
||||
|
||||
stats.append(list(measure_stats))
|
||||
|
||||
json_out = {}
|
||||
|
||||
for i in range(len(stats)):
|
||||
json_out[files[i]]=str(stats[i])
|
||||
stats.append(list(measure_stats))
|
||||
|
||||
json_out = {}
|
||||
|
||||
for i in range(len(stats)):
|
||||
json_out[files[i]]=str(stats[i])
|
||||
|
||||
print(json_out)
|
||||
print(json_out)
|
||||
|
||||
db.collection(u'stats').document(u'stats-noNN').set(json_out)
|
||||
db.collection(u'stats').document(u'stats-noNN').set(json_out)
|
||||
|
Loading…
Reference in New Issue
Block a user