From d490a8634c246e81b97366482040c1dab1bea580 Mon Sep 17 00:00:00 2001 From: ltcptgeneral Date: Mon, 16 Sep 2019 11:11:27 -0500 Subject: [PATCH] analysis.py v 1.1.0.004 --- .../__pycache__/analysis.cpython-37.pyc | Bin 6353 -> 6879 bytes data analysis/analysis/analysis.py | 34 ++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/data analysis/analysis/__pycache__/analysis.cpython-37.pyc b/data analysis/analysis/__pycache__/analysis.cpython-37.pyc index 366e447f651e8b061b27a1b3254812391ec0e35c..312a3c477055eb5751e888931443aebd26980fba 100644 GIT binary patch delta 1497 zcmbtTJ%|)Z6z=Nond#~I>*@L3A9Wq|q&@#uQB*{@6}?OZ#h~F_+O0yz>*-lv_bQ4o zftwmgfgp(NMurNeMuvjHUDzjxiHV7c$tCA|HEz2OCmdW4_3F*{e(Jri>iseQ?nrf^ zQn5Aso;@G^rp-R6cG<-TyU&j7u;>?gk(WbzQ1VMmL%o7}*)KEgSB+PBZB^qnQMqUM zRqk+ORr6~i&+FX1&v=8ItJ*#0I~mgCIfc|Sq{Z_JaWkaN3kqq7{OD_<4!0E4%$&M> zN+GQbndUPJX=lhR-=dI?LbhT-+xVP9x*4*a_Y^XfAv^d^g-j#Ts&fk4#eY)J47V?6 z-tHI2*q>FaFc1m!mtt9PuIFn=9n|D4XQ5s~^&zfUM`1B2y?E`^*e`Yb=a>8OVsJC) zhryLlq(+Kf0P40bGS~I<$a8f}waMr`@;B2?HJRRN9R&-zC2(dAA`Z zeGIfblb;(4hbh=I{oL}fA0;qH5j_-sE?ydfm^{=((@S~1dHMV}H@VXj@r%(A20_@r zBRm795J^p}Iff>AOca=mxqLZKP9ZtJct_qQH9S<=)9MFiVq+PXNJh|Xio8;T|t zG}G4G81LvdE3>k`M9tGjJ9(bQ6;s+oTVsj7X53}#<6T>4>pI>XJLj2DL=WGBLyP0C zvpPII9hH_r@cvTLA4YLnNU$xD#1lQGMOch)tOV%!o=#L{7_blZ|5H-x4#X&kHc~GN zfFZ!9>fmQQ0rryko~G0o#NxxIQVvX(LgXuUwxY7ZPGYX*6hpKthSoV7lax=*L6BVY z&G-f+iZIxZk^iw87{njZdxMyH)IH`~(Qx^8a%~vNpuK08>T6C}U?*-9Evd)(Nme_@ z$DZ4N>`A82GVC0mr<^{{6!+M_=Io*UZ(JLN_2lLDzM~YC8aD&@LDUYk|FbEI{(H0X zug)PhBdguc9@WZ0L~(|H4@Cgcm@%4_)V>siE8>j0%aT0P?VY7}0(3(_#EhqqdQhVX wlzkHy>Z0lKr`E~AkgtT|6s3(%$S2(`a~92k;TTrcwcLuEcS~;5&3*fQ0sChj-~a#s delta 977 zcmZ{iJ#5oZ5Xb%e6~|2+$N6#!ZPTI(83~DRQG^&G@iBA*F<1(c;h7NX*wJ%>R2YiX ztR2b|6Ksr(U07g5f(5~7kYHg!AZ9l1Ue&0I6kB(;fA_!hyLa#V`Ol}VcClzmaQ*rF zr1QJEYq_Mbd;Ho~Aq6o0fM7b*MU)wux^| zNQG*GlqRG~bwTV2snMJuWkGCO-;rs98iF~Yz7EA*DBh&=0#$?z$q{-~km`gi&_zLN z6S72Gg4C&bQ}UMgo{}#X@7P`4f<~FeKicgwHvJ4NmBAT=nR^T65+OD}=`=hHda|EO z!{M+OcQYkmUACVL5mrJ+z&+=E=Ua6ufCXRiP9@SCsB`(JN;s`iAo7~usJ72yvZwmm zAnC6KvUE0`F9q=@!0aaAO?ATlEnLqGTncTFgLB^}Zk zO5Dt!{GYpa0c&Q;qkzp&u0Z@3*ui4(+iURm%`+G0;nmmTQU7khaMQ&5V3T1, " - "Jacob Levine ," + "Arthur Lu ", + "Jacob Levine ", ) __all__ = [ @@ -131,6 +133,9 @@ __all__ = [ 'z_score', 'z_normalize', 'histo_analysis', + 'r_squared', + 'mse', + 'rms', # all statistics functions left out due to integration in other functions ] @@ -142,6 +147,8 @@ import csv import numba from numba import jit import numpy as np +import math +from sklearn import metrics from sklearn import preprocessing class error(ValueError): @@ -212,10 +219,25 @@ def histo_analysis(hist_data): derivative = t[1] / t[0] np.sort(derivative) - mean_derivative = basic_stats(derivative)[0] - stdev_derivative = basic_stats(derivative)[3] - return mean_derivative, stdev_derivative + return basic_stats(derivative)[0], basic_stats(derivative)[3] + +#regressions + +@jit(forceobj=True) +def r_squared(predictions, targets): # assumes equal size inputs + + return metrics.r2_score(np.array(targets), np.array(predictions)) + +@jit(forceobj=True) +def mse(predictions, targets): + + return metrics.mean_squared_error(np.array(targets), np.array(predictions)) + +@jit(forceobj=True) +def rms(predictions, targets): + + return math.sqrt(metrics.mean_squared_error(np.array(targets), np.array(predictions))) @jit(nopython=True) def mean(data):