superscript.py - v 1.

changelog:
- processes data more efficiently
This commit is contained in:
ltcptgeneral 2019-02-20 22:59:17 -06:00
parent f40ff03cb2
commit 6c665b10df
7 changed files with 134 additions and 46 deletions

View File

@ -423,7 +423,7 @@ def basic_stats(data, method, arg): # data=array, mode = ['1d':1d_basic_stats, '
data_t = []
for i in range (0, len(data) - 1, 1):
for i in range (0, len(data), 1):
data_t.append(float(data[i]))
_mean = mean(data_t)
@ -559,12 +559,15 @@ def stdev_z_split(mean, stdev, delta, low_bound, high_bound): #returns n-th perc
def histo_analysis(hist_data, delta, low_bound, high_bound):
if hist_data == 'debug':
return ('returns list of predicted values based on historical data; input delta for delta step in z-score and lower and higher bounds in number for standard deviations')
return ('returns list of predicted values based on historical data; input delta for delta step in z-score and lower and higher bounds in number of standard deviations')
derivative = []
for i in range(0, len(hist_data) - 1, 1):
derivative.append(float(hist_data[i + 1]) - float(hist_data [i]))
for i in range(0, len(hist_data), 1):
try:
derivative.append(float(hist_data[i - 1]) - float(hist_data [i]))
except:
pass
derivative_sorted = sorted(derivative, key=int)
mean_derivative = basic_stats(derivative_sorted,"1d", 0)[0]
@ -701,7 +704,7 @@ def tanh_regression(x, y):
def r_squared(predictions, targets): # assumes equal size inputs
return metrics.r2_score(targets, predictions)
return metrics.r2_score(np.array(targets), np.array(predictions))
def rms(predictions, targets): # assumes equal size inputs
@ -728,7 +731,7 @@ def calc_overfit(equation, rms_train, r2_train, x_test, y_test):
r2_test = r_squared(vals, y_test)
rms_test = rms(vals, y_test)
return rms_train - rms_test, r2_train - r2_test
return r2_train - r2_test
def strip_data(data, mode):
@ -747,7 +750,10 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
raise error("resolution must be int")
x_train = x
y_train = y
y_train = []
for i in range(len(y)):
y_train.append(float(y[i]))
x_test = []
y_test = []
@ -756,7 +762,7 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
index = random.randint(0, len(x) - 1)
x_test.append(x[index])
y_test.append(y[index])
y_test.append(float(y[index]))
x_train.pop(index)
y_train.pop(index)
@ -769,10 +775,13 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
r2s = []
for i in range (0, _range + 1, 1):
try:
x, y, z = poly_regression(x_train, y_train, i)
eqs.append(x)
rmss.append(y)
r2s.append(z)
except:
pass
for i in range (1, 100 * resolution + 1):
try:
@ -792,11 +801,14 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
except:
pass
try:
x, y, z = tanh_regression(x_train, y_train)
eqs.append(x)
rmss.append(y)
r2s.append(z)
except:
pass
for i in range (0, len(eqs), 1): #marks all equations where r2 = 1 as they 95% of the time overfit the data
if r2s[i] == 1:
@ -815,6 +827,7 @@ def optimize_regression(x, y, _range, resolution):#_range in poly regression is
overfit = []
for i in range (0, len(eqs), 1):
overfit.append(calc_overfit(eqs[i], rmss[i], r2s[i], x_test, y_test))
return eqs, rmss, r2s, overfit
@ -830,17 +843,16 @@ def select_best_regression(eqs, rmss, r2s, overfit, selector):
if selector == "min_overfit":
ind = np.argmax(overfit)
ind = np.argmin(overfit)
b_eq = eqs[ind]
b_rms = rmss[ind]
b_r2 = r2s[ind]
b_overfit = overfit[ind]
if selector == "max_rmss":
ind = np.argmax(rmss)
if selector == "max_r2s":
ind = np.argmax(r2s)
b_eq = eqs[ind]
b_rms = rmss[ind]
b_r2 = r2s[ind]

View File

@ -1 +1,5 @@
2022,4,4,4,4 2011,5,5,5,5,5 1101,6,6,6,6,6,6 821374,7,7,7 5,8,8,8
2022,4,5,10,15,8,954978,84,74
2011,3,6,9,12,15,7,856,9
1101,4,16,32,64,128,2,4234,-56
821374,7,8,9,79.33333333,170.3333333,636647,5874.666667,-121
5,4,8,8,103.8333333,230.3333333,1114135,7949.666667,-186

1 2022 4 4 5 4 10 4 2011 15 8 5 954978 5 84 5 74 5 1101 6 6 6 6 6 6 821374 7 7 7 5 8 8
2 2011 3 6 9 12 15 7 856 9
3 1101 4 16 32 64 128 2 4234 -56
4 821374 7 8 9 79.33333333 170.3333333 636647 5874.666667 -121
5 5 4 8 8 103.8333333 230.3333333 1114135 7949.666667 -186

View File

@ -0,0 +1,5 @@
-1.6007632575405175,3.094243071050249,4.583936305454976,7.237782504548598,-5.521589121433712,-2.9078766762969295,3.2751982610806145,3.669074500924099,6.194289395001171,-9.70395566576695,4.8593751222388235,-6.67094228013908,-4.144180498130141,-7.257062237714525,5.71197645401875,9.945491401171964,-2.7707351521125396,1.4555780053661849,2.2075220439544054,-7.918108528363314,0.6886619609074511,8.379762449827606,5.964876797994396,3.037103869702946,4.796017042338738,8.846961658102465,-8.238704985679558,4.530303869837741,-5.320585260639417,2.7702239357820417,-0.7832177468135537,9.256314936398226,-8.116813655472663,7.315710420609928,3.410242694024994,-8.10603846276264,-8.07153698072364,2.152085496135115,-3.0275379228407058,6.830181793819328,-4.29878946762698,9.088682964786567,-3.0116161280634612,2.111794120861081,1.1271566641715474,-0.35857566057631374,7.051881933450716,8.624850467592807,-9.140779075977711,-4.07202265033866,-2.246723549679377,-7.541531711756095,-2.4168165528412366,-2.7333638278084376,6.443589792007607,0.7905247877923074,0.30456961697296947,-3.990848124445174,-7.9156804373061345,9.162025498895577,-8.064463486673983,5.011434008083688,-8.958579081781028,6.271439236252764,-4.796406036363702,-3.485792580154259,-7.626666268770766,-8.897222191721939,-7.458882322500758,1.3507042532359428,-9.984387735385813,4.709713126273524,5.937388844487694,-6.1309191195400725,-5.786143582459921,8.250793995102445,7.991120247882058,-0.829775210764117,-2.892320256799506,5.713355349767738,-4.291238046532964,5.388711926791316,4.6898933351779135,8.518246578598415,5.737025842395383,-5.025250884552543,5.4223386703040095,-0.7664691196370974,-1.6417217237143138,0.15989165426631047,1.291931036048135,-1.2477263925023596,-8.385094769816812,6.680157017788698,9.200962867930386,4.438716964910279,0.05664451323347208,2.9767752824462654,9.862390452775337,-4.638188933411371
-4.19886514948963,2.116259832903374,9.784780806656713,-6.0262515990655245,2.259850780278308,5.311171798094897,3.164512882950646,4.350057506858846,7.693618498503586,-1.0820047325626003,6.008893820630796,6.959235712776991,-2.96741010662738,-5.39553133393701,7.687926117869168,-2.214421295339248,-6.563678258550183,3.948911670515244,7.853521046343122,-6.343085246017093,2.56780495027966,-3.232660420633284,2.709342092804402,-8.913853676046354,2.628378579583048,-8.864398454413786,-6.211965077084363,8.779612488518271,1.5594177199635304,-9.772430538411676,3.7679334925591945,-2.8048191086500314,-8.586986980341946,-2.4926295457304093,-4.852547317818196,9.507065105074783,-3.566533536225176,8.196094739800053,2.2637934849874988,6.6155224065612614,-4.0133698637219,-5.911477528422056,2.6049117208119554,-1.5479147894596945,2.594762318154176,-6.7868329999599535,3.113136409844607,9.663942737830045,-7.31890030980084,-4.294092860785357,-4.288178288293631,-2.37970443013519,4.835033320384534,2.9259330858634556,-5.997674611760145,0.4356291979954996,4.836551398108565,9.782096211874464,-9.585544246376953,8.271693526960206,-2.2178050388803605,2.641436188891788,-6.023516481952649,9.792991730773505,-1.0952307943365458,6.379482453639433,7.876314648269901,3.822529107554015,8.882663756536772,5.4924638799010985,4.836648299842416,-1.6546484549283047,-3.758054369040682,-7.098680827220005,4.286604047728407,9.684572924081003,-9.275783902012751,-2.186978098830334,4.343146232468751,4.555468474798047,-4.42979277112862,5.520571646152758,-1.2990764806053807,0.08646762204405789,9.36820098083734,8.882177934124492,-9.05491849330825,7.675706379209121,0.7238793778833781,-2.8640931838596835,3.350602837405848,-6.7814627959535585,-2.0879701330108595,8.692522507298118,0.20922204583939852,-7.3232930928669475,-1.6927613308994474,3.9410921827987355,2.6057819490036422,-3.527273801049575
6.788176993183889,6.862067286093868,5.833904296143984,-7.781034990188223,-6.349861604578797,5.599429977462325,2.015866273348969,-2.69247225804762,-9.216547862186925,1.264916962009977,0.08401595107666893,9.917929998283142,-0.3864740845943011,-5.300332868087949,0.28279740984828194,1.999495568209264,9.796631321834493,5.103888673210392,-1.0985864676389063,-1.5412686471497246,-9.055241757520072,-0.5146482007524771,7.619194187802897,-4.1503833583696315,-0.3967432906038759,-0.4864090139476289,2.0360061099349025,-1.7463749583944566,8.4807959990187,1.3567113623871876,3.568261226995567,7.436380867538176,2.7028531935229783,4.486970484574863,-1.5467004743898922,6.0296370906970616,-6.7369240379420825,2.789651300988451,4.9704006218532015,-1.075946622454973,9.022213731351385,6.103384581033261,-4.342334480326942,-1.5776770692904698,1.8555732666933125,-8.26014778013041,-2.9271472441879993,-7.810696622831273,-6.536772085042653,2.618363185220005,9.093874506934746,4.463338556116641,-1.3361678673511506,-3.874381482625207,-0.9331966743045896,2.8510099645779725,-2.9328414500285183,9.386495801036943,-1.0023751510178958,0.5229070405110505,-6.24551207787964,-6.8504950428095075,-2.581577003118321,2.759811742759439,-1.804713614337011,-9.60042177306402,-9.898981802243851,-5.808497690078598,-0.5070644534586322,-1.2974125856247802,2.4093179067071517,2.8665147335929575,6.393258617174254,7.280679378243889,1.3745005338887673,0.9585421043585711,-8.975335523683107,3.6950794022708973,-7.151413979451203,5.699888181294208,-1.0575200368490734,-6.947763211211018,-8.279391361362169,2.621379758754605,9.922894779226297,-2.9987218632524044,-6.14101642356731,-5.780200240971309,-3.3629391352116382,-0.7094394581177674,3.8115190778355146,3.663733013840126,3.0448836904165493,-4.836194399270624,-6.204235948856152,-3.5454861540508027,-3.6289943832681315,-4.926973636594846,1.929539157963685,-5.707193276216477
3.8701390396012503,3.72211796922735,-8.3173593943796,-7.573638821535475,4.497048092967994,-7.090224839928398,-2.858973055799181,-3.9675071751204927,8.118104390558031,-3.035703777612639,6.143842252086614,9.344160143193434,0.44978790546838,4.152209850708186,-7.85126223252504,3.985406626103213,9.822705825998092,-9.069999300868849,-1.8464352352043552,-1.9734894041532876,-4.270485352545785,4.562277246020372,0.5269846427943783,0.3061663733159996,-4.521067049398009,2.235492351632489,-4.456588818332861,-4.368939266916698,9.369163690680644,-3.3193405029646854,6.525452810384849,4.461622056905547,-5.032674188831445,6.821617318330514,3.8886417531298196,-4.184603705098214,9.066727575306317,2.687267855530335,4.520000851288042,-4.930734125502991,4.5907333299034825,-8.694259690971434,8.667506918363877,-0.6275183762328158,-3.862316803080015,9.41600832901458,2.979008367035515,-6.20243149904089,-3.332676616421704,-5.5557033612352935,0.9507517317031517,-5.489694132848346,-3.7628387956086335,8.67243880115295,-5.962764825474089,1.221636178578052,-0.5675768518028885,5.095191299331823,7.800122836783583,-2.491420276056038,6.57120498281018,6.534666101422218,-0.8828517642680254,-0.41707488666616754,-0.989539488954458,-4.901917852365994,-8.045342911556068,6.052011997089949,6.5075875487304415,2.6079668780768355,9.189972367365598,-4.432459111233953,-2.78611599182965,-4.995783049643354,-5.26322819616033,-2.65059330269491,-5.174714623994008,3.77315031383052,9.677144856280869,-4.866644001663616,7.430603283465139,0.7186235512705448,-0.053740761500133516,0.559034042556652,-9.639523751952147,6.172203675068133,7.347569661731825,-5.400339869061341,-4.962585034208242,-0.821490256858592,-9.202987798708255,-0.6992764031929699,9.720892911740641,-0.5544875651248393,-9.991691645579143,-6.413472391882906,-9.449949818312549,8.74042983409667,-8.737937346494473,7.406621385403163
9.459443630130309,7.016111056779078,0.9921215455341255,-6.550347195636091,-1.1500161987948836,5.025520665751312,0.11820321329195416,-6.098011869080235,-7.059777773821221,9.918747974386516,0.5740936358815105,-6.074495459736933,-2.8562420467646437,2.7452132300248024,0.3961615673831034,-8.187709255602321,-2.223162885896828,2.02308233068765,2.173861910822211,7.467631143535776,-6.869303813419824,5.515660829109667,-1.1854728450344822,-7.244540221731035,-2.47741275462168,1.7005021142373273,-2.6435277014190124,2.914197127354111,-5.321090657621217,-3.405385672515453,-7.2390700266735974,-2.2543430838554563,0.5810520220327327,-3.662068584206102,-0.712093105965403,-7.033992941249638,8.947547833409896,-9.761463728561306,6.032536612477848,8.373114739282794,-9.188001492119549,-0.792249220135929,-2.286873900824819,9.12725915348836,9.847383433934262,-4.308017192739209,0.06416205096922312,8.989864884806554,-9.575146040499348,-1.4826049056824822,1.2457815252508393,-5.805141241281417,-8.534557544196815,3.76303051544658,-6.315166870161935,-0.8469444777475754,2.2715479997134445,7.940699113699367,2.0789925133343736,-4.539705528462939,-9.929346289529747,0.08885331451507206,6.586247829508064,7.617817013533614,7.1824527157653435,4.756418030566145,5.607378052322925,7.6483759904306226,-3.347173860635875,-6.528030394514559,7.727623706277711,-7.00049327736375,0.10327904242857677,7.5340647071513445,6.334205397937531,5.577405123406242,9.299609203382204,8.843550733594356,2.856351085240723,0.7394015204831224,-3.8778018128261316,3.6571621070359726,-8.185370601499404,5.933614053714207,-2.8773431938656158,8.796763464112626,-8.643277711461923,6.9056764000134265,-3.3536123917078537,-5.92664281813291,-6.513654020344379,2.1204729995170943,4.571033504057793,1.7282198881806465,-8.785991084685492,-0.5406625828468776,5.042946509631578,-6.18310119331984,-7.877843185844262,5.173734304035298
1 -1.6007632575405175 3.094243071050249 4.583936305454976 7.237782504548598 -5.521589121433712 -2.9078766762969295 3.2751982610806145 3.669074500924099 6.194289395001171 -9.70395566576695 4.8593751222388235 -6.67094228013908 -4.144180498130141 -7.257062237714525 5.71197645401875 9.945491401171964 -2.7707351521125396 1.4555780053661849 2.2075220439544054 -7.918108528363314 0.6886619609074511 8.379762449827606 5.964876797994396 3.037103869702946 4.796017042338738 8.846961658102465 -8.238704985679558 4.530303869837741 -5.320585260639417 2.7702239357820417 -0.7832177468135537 9.256314936398226 -8.116813655472663 7.315710420609928 3.410242694024994 -8.10603846276264 -8.07153698072364 2.152085496135115 -3.0275379228407058 6.830181793819328 -4.29878946762698 9.088682964786567 -3.0116161280634612 2.111794120861081 1.1271566641715474 -0.35857566057631374 7.051881933450716 8.624850467592807 -9.140779075977711 -4.07202265033866 -2.246723549679377 -7.541531711756095 -2.4168165528412366 -2.7333638278084376 6.443589792007607 0.7905247877923074 0.30456961697296947 -3.990848124445174 -7.9156804373061345 9.162025498895577 -8.064463486673983 5.011434008083688 -8.958579081781028 6.271439236252764 -4.796406036363702 -3.485792580154259 -7.626666268770766 -8.897222191721939 -7.458882322500758 1.3507042532359428 -9.984387735385813 4.709713126273524 5.937388844487694 -6.1309191195400725 -5.786143582459921 8.250793995102445 7.991120247882058 -0.829775210764117 -2.892320256799506 5.713355349767738 -4.291238046532964 5.388711926791316 4.6898933351779135 8.518246578598415 5.737025842395383 -5.025250884552543 5.4223386703040095 -0.7664691196370974 -1.6417217237143138 0.15989165426631047 1.291931036048135 -1.2477263925023596 -8.385094769816812 6.680157017788698 9.200962867930386 4.438716964910279 0.05664451323347208 2.9767752824462654 9.862390452775337 -4.638188933411371
2 -4.19886514948963 2.116259832903374 9.784780806656713 -6.0262515990655245 2.259850780278308 5.311171798094897 3.164512882950646 4.350057506858846 7.693618498503586 -1.0820047325626003 6.008893820630796 6.959235712776991 -2.96741010662738 -5.39553133393701 7.687926117869168 -2.214421295339248 -6.563678258550183 3.948911670515244 7.853521046343122 -6.343085246017093 2.56780495027966 -3.232660420633284 2.709342092804402 -8.913853676046354 2.628378579583048 -8.864398454413786 -6.211965077084363 8.779612488518271 1.5594177199635304 -9.772430538411676 3.7679334925591945 -2.8048191086500314 -8.586986980341946 -2.4926295457304093 -4.852547317818196 9.507065105074783 -3.566533536225176 8.196094739800053 2.2637934849874988 6.6155224065612614 -4.0133698637219 -5.911477528422056 2.6049117208119554 -1.5479147894596945 2.594762318154176 -6.7868329999599535 3.113136409844607 9.663942737830045 -7.31890030980084 -4.294092860785357 -4.288178288293631 -2.37970443013519 4.835033320384534 2.9259330858634556 -5.997674611760145 0.4356291979954996 4.836551398108565 9.782096211874464 -9.585544246376953 8.271693526960206 -2.2178050388803605 2.641436188891788 -6.023516481952649 9.792991730773505 -1.0952307943365458 6.379482453639433 7.876314648269901 3.822529107554015 8.882663756536772 5.4924638799010985 4.836648299842416 -1.6546484549283047 -3.758054369040682 -7.098680827220005 4.286604047728407 9.684572924081003 -9.275783902012751 -2.186978098830334 4.343146232468751 4.555468474798047 -4.42979277112862 5.520571646152758 -1.2990764806053807 0.08646762204405789 9.36820098083734 8.882177934124492 -9.05491849330825 7.675706379209121 0.7238793778833781 -2.8640931838596835 3.350602837405848 -6.7814627959535585 -2.0879701330108595 8.692522507298118 0.20922204583939852 -7.3232930928669475 -1.6927613308994474 3.9410921827987355 2.6057819490036422 -3.527273801049575
3 6.788176993183889 6.862067286093868 5.833904296143984 -7.781034990188223 -6.349861604578797 5.599429977462325 2.015866273348969 -2.69247225804762 -9.216547862186925 1.264916962009977 0.08401595107666893 9.917929998283142 -0.3864740845943011 -5.300332868087949 0.28279740984828194 1.999495568209264 9.796631321834493 5.103888673210392 -1.0985864676389063 -1.5412686471497246 -9.055241757520072 -0.5146482007524771 7.619194187802897 -4.1503833583696315 -0.3967432906038759 -0.4864090139476289 2.0360061099349025 -1.7463749583944566 8.4807959990187 1.3567113623871876 3.568261226995567 7.436380867538176 2.7028531935229783 4.486970484574863 -1.5467004743898922 6.0296370906970616 -6.7369240379420825 2.789651300988451 4.9704006218532015 -1.075946622454973 9.022213731351385 6.103384581033261 -4.342334480326942 -1.5776770692904698 1.8555732666933125 -8.26014778013041 -2.9271472441879993 -7.810696622831273 -6.536772085042653 2.618363185220005 9.093874506934746 4.463338556116641 -1.3361678673511506 -3.874381482625207 -0.9331966743045896 2.8510099645779725 -2.9328414500285183 9.386495801036943 -1.0023751510178958 0.5229070405110505 -6.24551207787964 -6.8504950428095075 -2.581577003118321 2.759811742759439 -1.804713614337011 -9.60042177306402 -9.898981802243851 -5.808497690078598 -0.5070644534586322 -1.2974125856247802 2.4093179067071517 2.8665147335929575 6.393258617174254 7.280679378243889 1.3745005338887673 0.9585421043585711 -8.975335523683107 3.6950794022708973 -7.151413979451203 5.699888181294208 -1.0575200368490734 -6.947763211211018 -8.279391361362169 2.621379758754605 9.922894779226297 -2.9987218632524044 -6.14101642356731 -5.780200240971309 -3.3629391352116382 -0.7094394581177674 3.8115190778355146 3.663733013840126 3.0448836904165493 -4.836194399270624 -6.204235948856152 -3.5454861540508027 -3.6289943832681315 -4.926973636594846 1.929539157963685 -5.707193276216477
4 3.8701390396012503 3.72211796922735 -8.3173593943796 -7.573638821535475 4.497048092967994 -7.090224839928398 -2.858973055799181 -3.9675071751204927 8.118104390558031 -3.035703777612639 6.143842252086614 9.344160143193434 0.44978790546838 4.152209850708186 -7.85126223252504 3.985406626103213 9.822705825998092 -9.069999300868849 -1.8464352352043552 -1.9734894041532876 -4.270485352545785 4.562277246020372 0.5269846427943783 0.3061663733159996 -4.521067049398009 2.235492351632489 -4.456588818332861 -4.368939266916698 9.369163690680644 -3.3193405029646854 6.525452810384849 4.461622056905547 -5.032674188831445 6.821617318330514 3.8886417531298196 -4.184603705098214 9.066727575306317 2.687267855530335 4.520000851288042 -4.930734125502991 4.5907333299034825 -8.694259690971434 8.667506918363877 -0.6275183762328158 -3.862316803080015 9.41600832901458 2.979008367035515 -6.20243149904089 -3.332676616421704 -5.5557033612352935 0.9507517317031517 -5.489694132848346 -3.7628387956086335 8.67243880115295 -5.962764825474089 1.221636178578052 -0.5675768518028885 5.095191299331823 7.800122836783583 -2.491420276056038 6.57120498281018 6.534666101422218 -0.8828517642680254 -0.41707488666616754 -0.989539488954458 -4.901917852365994 -8.045342911556068 6.052011997089949 6.5075875487304415 2.6079668780768355 9.189972367365598 -4.432459111233953 -2.78611599182965 -4.995783049643354 -5.26322819616033 -2.65059330269491 -5.174714623994008 3.77315031383052 9.677144856280869 -4.866644001663616 7.430603283465139 0.7186235512705448 -0.053740761500133516 0.559034042556652 -9.639523751952147 6.172203675068133 7.347569661731825 -5.400339869061341 -4.962585034208242 -0.821490256858592 -9.202987798708255 -0.6992764031929699 9.720892911740641 -0.5544875651248393 -9.991691645579143 -6.413472391882906 -9.449949818312549 8.74042983409667 -8.737937346494473 7.406621385403163
5 9.459443630130309 7.016111056779078 0.9921215455341255 -6.550347195636091 -1.1500161987948836 5.025520665751312 0.11820321329195416 -6.098011869080235 -7.059777773821221 9.918747974386516 0.5740936358815105 -6.074495459736933 -2.8562420467646437 2.7452132300248024 0.3961615673831034 -8.187709255602321 -2.223162885896828 2.02308233068765 2.173861910822211 7.467631143535776 -6.869303813419824 5.515660829109667 -1.1854728450344822 -7.244540221731035 -2.47741275462168 1.7005021142373273 -2.6435277014190124 2.914197127354111 -5.321090657621217 -3.405385672515453 -7.2390700266735974 -2.2543430838554563 0.5810520220327327 -3.662068584206102 -0.712093105965403 -7.033992941249638 8.947547833409896 -9.761463728561306 6.032536612477848 8.373114739282794 -9.188001492119549 -0.792249220135929 -2.286873900824819 9.12725915348836 9.847383433934262 -4.308017192739209 0.06416205096922312 8.989864884806554 -9.575146040499348 -1.4826049056824822 1.2457815252508393 -5.805141241281417 -8.534557544196815 3.76303051544658 -6.315166870161935 -0.8469444777475754 2.2715479997134445 7.940699113699367 2.0789925133343736 -4.539705528462939 -9.929346289529747 0.08885331451507206 6.586247829508064 7.617817013533614 7.1824527157653435 4.756418030566145 5.607378052322925 7.6483759904306226 -3.347173860635875 -6.528030394514559 7.727623706277711 -7.00049327736375 0.10327904242857677 7.5340647071513445 6.334205397937531 5.577405123406242 9.299609203382204 8.843550733594356 2.856351085240723 0.7394015204831224 -3.8778018128261316 3.6571621070359726 -8.185370601499404 5.933614053714207 -2.8773431938656158 8.796763464112626 -8.643277711461923 6.9056764000134265 -3.3536123917078537 -5.92664281813291 -6.513654020344379 2.1204729995170943 4.571033504057793 1.7282198881806465 -8.785991084685492 -0.5406625828468776 5.042946509631578 -6.18310119331984 -7.877843185844262 5.173734304035298

View File

@ -1 +1,5 @@
2022,1,2,3,4 2011,5,6,7,8 1101,1000,2000,3000,4000 821374,0,0,0,0 5,3,5,6
2022,1,2,3,4,5,6,7,8
2011,5,6,7,8,9,10,11,12
1101,1000,2000,3000,4000,5000,6000,7000,8000
821374,0,0,0,0,0,0,0,1
5,3,5,6,7,8.5,9.8,11.1,12.4

1 2022 1 2 3 4 2011 4 5 6 7 8 1101 8 1000 2000 3000 4000 821374 0 0 0 0 5 3 5 6
2 2011 5 6 7 8 9 10 11 12
3 1101 1000 2000 3000 4000 5000 6000 7000 8000
4 821374 0 0 0 0 0 0 0 1
5 5 3 5 6 7 8.5 9.8 11.1 12.4

View File

@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "titanscoutandroid",
"private_key_id": "4fa61815e17c0b5c4dfe48445d87f8fc6d07a5d8",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDZCkE1rcJnk7Cf\n/cWlQoOTl/L4qUmUSOgeG9yGDYLEhedSCaR79xKMZQdVWkGGI3FXS2E4OQVXJwUy\nDh/iiIOOPvRvHeDsK2hBPmy8P3MIkbrUDFeD1HrhgKAsxOmaAswUhZxua2Dkn8+p\nqnF2fs1I3tBTyNehGTi0Jz8uLTYH8iIprOb27eOBLR+qkSSP9qUOgZjP76+Kk5WA\niur9EFk/ZCDjb6vgxNwrkQ6oKaH31A3bNeLNYW6+hqOQgYJpX/WwNCLLbtLs+Ywf\nnuk3pHZyw+y4xgKWagDbh8joaGt4s2jUYwvIVSQwy0UAzdd9HnVsi24vXhxbPpcu\nwjFPVMMDAgMBAAECggEAHCUGyMG0FH9j55Nedmw2KMULBnDZcEe2BfWB9sY4v2hH\n020ZrdOfzaHqPgi6t3zQHUxSmppWVXNjapbHTrZ6LM+AHgqnWKjWV6OTMSQfNCzF\np+rDzH4YwzZNTxDn5AdZ1I1w+CanhW4t3SgTl5Sg5UKzjDHeuG7PWhk+yaumNohU\nAHHSNjfF+CCuRlSswU6IpZP9x5bG5jT9UivGvB1u6E/5I1oDlplQIzEnay/QDd2p\nePYw+/QsvkLChSI7igsnXzGqwRSfql/4qk4hkmTY02j4V32uOEgXiA0ysDGC5SEy\nuSc996LF36r3iQE9WVqmmlVT7/wAtUIjxGuB6rBcEQKBgQDsViqX2bszdQt0Hx8g\nF4L2q8Fv0GJOK2JKy9nxvMa6xg1esf0vHzcovICUy4tznFB6BKQbeKlI5A0t3BdL\nWLec1+l1001DJLQFbAWlMp7NrCMZ9McWIDSyM0DgN1cZg0ijJegJgRz8ZmW933U+\n/D8wPtrGm114ynhq5Pkt8tWYUQKBgQDrGRVVom6sA46ZAPEHQefSWWSuVcroKFOw\n/6JhxBnAwvaIQcTviUWQedrLJ0VLyEBZEIVmVKOkrEu9XtfP8iMhe8SR3b8/eXsZ\nQaorG2+gEAdqHp68Fd2YRgYnBPQ/syyDMImVtCMCQlndOPghnsygGukU8fkOpREH\nHVxRwBrlEwKBgDQiWej/fd0/D5TBHMOejCRQBS7eQCFQTrGDQIOkCg6/i8l86AYS\nE7/nvVGViSCqtdIE3hK1Tlqm/AVGzNixLGfr9TMptpx+Jzwe9SvY+9ERDPk31wcZ\neaZpygDsFEmrfUWIIiSel79R81WsSpfnWyUQaIBxW3A+8cta0WECdX3RAoGAUGed\nwlHxY+c7h9yokoDZ1jk4k99HrCrOpMRpNuKopCKJyoQj5ICgSA9E4yIlMwvj5hIe\nbacY6KL8rGGZkccQeM0pp3GdjQnxLewlVOTnQmj5ADREubMIvKGGTSYGmxqeaKfb\nBlY7evRSY7SuOGFlPoS1nrI7KeUOc8542oTHLf0CgYB0jE+FZAX+mtQViddS9IkA\nsOTtAYArA7GlGZNGzShOUghJIFZk37+9TeryzYga4bTto0yAHUWbjD6kzbkEGFPj\nwwOHb1w3UdVRGh2ruEQxN59wHvCrrAqRrtJ7sKFsfKea4/twPv/CRnGhMa645Dbo\nSBMA/OHEodv06XqibcgovA==\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-wpsvx@titanscoutandroid.iam.gserviceaccount.com",
"client_id": "114864465329268712237",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-wpsvx%40titanscoutandroid.iam.gserviceaccount.com"
}

View File

@ -6,6 +6,8 @@
__version__ = "1.0.3.000"
__changelog__ = """changelog:
1.0.3.001:
- processes data more efficiently
1.0.3.000:
- actually processes data
1.0.2.000:
@ -23,13 +25,26 @@ __author__ = (
"Jacob Levine <jlevine@ttic.edu>,"
)
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
import analysis
import titanlearn
import visualization
import os
import glob
import numpy as np
# Use a service account
cred = credentials.Certificate('keys/titanscoutandroid_firebase.json')
firebase_admin.initialize_app(cred)
db = firestore.client()
#get all the data
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 = []
@ -50,14 +65,50 @@ 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
measure_stats = []
for i in range(len(measure)): #unpacks into specific teams
ofbest_curve = [None]
r2best_curve = [None]
line = measure[i]
line.pop(0) #removes team identifier
measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)))
#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)
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))
print (stats)
# print(d)
json_out = {}
#print (stats)
for i in range(len(stats)):
json_out[files[i]]=stats[i]
db.collection(u'stats').document(u'stats-noNN').set(json_out)