mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-13 22:56:18 +00:00
analysis.py v 2.2.2
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
73a16b8397
commit
3763cb041f
@ -7,12 +7,15 @@
|
|||||||
# current benchmark of optimization: 1.33 times faster
|
# current benchmark of optimization: 1.33 times faster
|
||||||
# setup:
|
# setup:
|
||||||
|
|
||||||
__version__ = "2.2.1"
|
__version__ = "2.2.2"
|
||||||
|
|
||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
|
2.2.2:
|
||||||
|
- fixed 2.2.1 changelog entry
|
||||||
|
- changed regression to return dictionary
|
||||||
2.2.1:
|
2.2.1:
|
||||||
changed all references to parent package analysis to tra_analysis
|
- changed all references to parent package analysis to tra_analysis
|
||||||
2.2.0:
|
2.2.0:
|
||||||
- added Sort class
|
- added Sort class
|
||||||
- added several array sorting functions to Sort class including:
|
- added several array sorting functions to Sort class including:
|
||||||
@ -424,7 +427,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
X = np.array(inputs)
|
X = np.array(inputs)
|
||||||
y = np.array(outputs)
|
y = np.array(outputs)
|
||||||
|
|
||||||
regressions = []
|
regressions = {}
|
||||||
|
|
||||||
if 'lin' in args: # formula: ax + b
|
if 'lin' in args: # formula: ax + b
|
||||||
|
|
||||||
@ -437,7 +440,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
popt, pcov = scipy.optimize.curve_fit(lin, X, y)
|
popt, pcov = scipy.optimize.curve_fit(lin, X, y)
|
||||||
|
|
||||||
coeffs = popt.flatten().tolist()
|
coeffs = popt.flatten().tolist()
|
||||||
regressions.append(str(coeffs[0]) + "*x+" + str(coeffs[1]))
|
regressions["lin"] = (str(coeffs[0]) + "*x+" + str(coeffs[1]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -454,7 +457,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
popt, pcov = scipy.optimize.curve_fit(log, X, y)
|
popt, pcov = scipy.optimize.curve_fit(log, X, y)
|
||||||
|
|
||||||
coeffs = popt.flatten().tolist()
|
coeffs = popt.flatten().tolist()
|
||||||
regressions.append(str(coeffs[0]) + "*log(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
regressions["log"] = (str(coeffs[0]) + "*log(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -471,7 +474,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
popt, pcov = scipy.optimize.curve_fit(exp, X, y)
|
popt, pcov = scipy.optimize.curve_fit(exp, X, y)
|
||||||
|
|
||||||
coeffs = popt.flatten().tolist()
|
coeffs = popt.flatten().tolist()
|
||||||
regressions.append(str(coeffs[0]) + "*e^(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
regressions["exp"] = (str(coeffs[0]) + "*e^(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -482,7 +485,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
inputs = np.array([inputs])
|
inputs = np.array([inputs])
|
||||||
outputs = np.array([outputs])
|
outputs = np.array([outputs])
|
||||||
|
|
||||||
plys = []
|
plys = {}
|
||||||
limit = len(outputs[0])
|
limit = len(outputs[0])
|
||||||
|
|
||||||
for i in range(2, limit):
|
for i in range(2, limit):
|
||||||
@ -500,9 +503,9 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
for param in params:
|
for param in params:
|
||||||
temp += "(" + str(param) + "*x^" + str(counter) + ")"
|
temp += "(" + str(param) + "*x^" + str(counter) + ")"
|
||||||
counter += 1
|
counter += 1
|
||||||
plys.append(temp)
|
plys["x^" + str(i)] = (temp)
|
||||||
|
|
||||||
regressions.append(plys)
|
regressions["ply"] = (plys)
|
||||||
|
|
||||||
if 'sig' in args: # formula: a tanh (b(x + c)) + d
|
if 'sig' in args: # formula: a tanh (b(x + c)) + d
|
||||||
|
|
||||||
@ -515,7 +518,7 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
popt, pcov = scipy.optimize.curve_fit(sig, X, y)
|
popt, pcov = scipy.optimize.curve_fit(sig, X, y)
|
||||||
|
|
||||||
coeffs = popt.flatten().tolist()
|
coeffs = popt.flatten().tolist()
|
||||||
regressions.append(str(coeffs[0]) + "*tanh(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
regressions["sig"] = (str(coeffs[0]) + "*tanh(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user