From 98a2519f42907e29cddead6d2e3b133f0f8dd2eb Mon Sep 17 00:00:00 2001 From: ltcptgeneral <35508619+ltcptgeneral@users.noreply.github.com> Date: Mon, 4 Mar 2019 16:38:40 -0600 Subject: [PATCH] lotta bug fixes --- .../__pycache__/analysis.cpython-37.pyc | Bin 25263 -> 25263 bytes .../__pycache__/titanlearn.cpython-37.pyc | Bin 5410 -> 5402 bytes data analysis/analysis.py | 2 +- data analysis/data/scores.csv | 1 + data analysis/superscript.py | 82 ++++++++++++++++-- data analysis/titanlearn.py | 2 +- 6 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 data analysis/data/scores.csv diff --git a/data analysis/__pycache__/analysis.cpython-37.pyc b/data analysis/__pycache__/analysis.cpython-37.pyc index 1a78a7f09ae17e8f194b7afba15a48540d331b49..299a28cf7ccd6caaba8ba8ed590dbf634c5151c3 100644 GIT binary patch delta 35 ncmZ2~lyUu0Ms6owUM>b85a_7g$o;{M9mHl}c(9qteXTSAsyPV` delta 35 ncmZ2~lyUu0Ms6owUM>b8Xtk`~$o;{Meb!76xVf3heXTSA&rb}( diff --git a/data analysis/__pycache__/titanlearn.cpython-37.pyc b/data analysis/__pycache__/titanlearn.cpython-37.pyc index 7be8234faea11aaf82a9ac31044af43a6124769a..5877577c18768ca5750ac68d5f70139d561abe6b 100644 GIT binary patch delta 36 qcmZ3aHA{=viIMy1KWMN|Qz4GHl8 delta 46 zcmbQGwMdKCiId$((TdH_710%!6V|pTtDwDs8s4{VI0092w B3kv`M diff --git a/data analysis/analysis.py b/data analysis/analysis.py index ece02176..c3cc4fd0 100644 --- a/data analysis/analysis.py +++ b/data analysis/analysis.py @@ -758,7 +758,7 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is x_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) x_test.append(x[index]) diff --git a/data analysis/data/scores.csv b/data analysis/data/scores.csv new file mode 100644 index 00000000..5562ec8a --- /dev/null +++ b/data analysis/data/scores.csv @@ -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 \ No newline at end of file diff --git a/data analysis/superscript.py b/data analysis/superscript.py index 90b23298..4371e8b7 100644 --- a/data analysis/superscript.py +++ b/data analysis/superscript.py @@ -41,6 +41,7 @@ import firebase_admin from firebase_admin import credentials from firebase_admin import firestore import analysis +import titanlearn import visualization import os 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 data = [] 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: data.append(analysis.load_csv(i)) @@ -67,6 +68,7 @@ def titanservice(): stats = [] measure_stats = [] teams = analysis.load_csv("data/teams.csv") + scores = analysis.load_csv("data/scores.csv") end = time.time() @@ -111,19 +113,82 @@ def titanservice(): 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) + 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 = {} + 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) - for i in range(len(stats)): - json_out[files[i]]=str(stats[i]) + ofbest_curve.append(beqs) + ofbest_curve.append(brmss) + ofbest_curve.append(br2s) + ofbest_curve.append(boverfit) + ofbest_curve.pop(0) - #print(json_out) + #print(ofbest_curve) - db.collection(u'stats').document(u'stats-noNN').set(json_out) + 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 = {} + score_out = {} + + #print(stats) + + 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) + + #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(): #TODO @@ -173,3 +238,4 @@ firebase_admin.initialize_app(cred) db = firestore.client() service() #finally we write something that isn't a function definition +#titanservice() diff --git a/data analysis/titanlearn.py b/data analysis/titanlearn.py index 0578a875..a32bceaa 100644 --- a/data analysis/titanlearn.py +++ b/data analysis/titanlearn.py @@ -198,4 +198,4 @@ def retyuoipufdyu(): model = linear_nn(8, 100, 1, 20, act_fn = "relu") print(model) return train_sgd_simple(model,"regression", data, ground, learnrate=1e-4, iters=1000) -retyuoipufdyu() +#retyuoipufdyu()