From d83d56772d0a7c73cb80d2c27b400fa56d122652 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 14 May 2020 23:36:28 -0500 Subject: [PATCH] analysis.py v 1.2.2.000 Signed-off-by: Arthur Lu --- analysis-master/analysis/analysis.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/analysis-master/analysis/analysis.py b/analysis-master/analysis/analysis.py index c4cf49de..07ff32e6 100644 --- a/analysis-master/analysis/analysis.py +++ b/analysis-master/analysis/analysis.py @@ -7,10 +7,12 @@ # current benchmark of optimization: 1.33 times faster # setup: -__version__ = "1.2.1.002" +__version__ = "1.2.2.000" # changelog should be viewed using print(analysis.__changelog__) __changelog__ = """changelog: + 1.2.2.000: + - changed output of regressions to function strings instead of list of coefficients 1.2.1.002: - renamed ArrayTest class to Array 1.2.1.001: @@ -412,7 +414,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array popt, pcov = scipy.optimize.curve_fit(lin, X, y) - regressions.append((popt.flatten().tolist(), None)) + coeffs = popt.flatten().tolist() + regressions.append(str(coeffs[0]) + "*x+" + str(coeffs[1])) except Exception as e: @@ -428,7 +431,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array popt, pcov = scipy.optimize.curve_fit(log, X, y) - regressions.append((popt.flatten().tolist(), None)) + coeffs = popt.flatten().tolist() + regressions.append(str(coeffs[0]) + "*log(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3])) except Exception as e: @@ -444,7 +448,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array popt, pcov = scipy.optimize.curve_fit(exp, X, y) - regressions.append((popt.flatten().tolist(), None)) + coeffs = popt.flatten().tolist() + regressions.append(str(coeffs[0]) + "*e^(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3])) except Exception as e: @@ -466,10 +471,14 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array params = model.steps[1][1].intercept_.tolist() params = np.append(params, model.steps[1][1].coef_[0].tolist()[1::]) - params.flatten() - params = params.tolist() - - plys.append(params) + params = params.flatten().tolist() + + temp = "" + counter = 0 + for param in params: + temp += "(" + str(param) + "*x^" + str(counter) + ")" + counter += 1 + plys.append(temp) regressions.append(plys) @@ -483,7 +492,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array popt, pcov = scipy.optimize.curve_fit(sig, X, y) - regressions.append((popt.flatten().tolist(), None)) + coeffs = popt.flatten().tolist() + regressions.append(str(coeffs[0]) + "*tanh(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3])) except Exception as e: