2 years ago

#31669

test-img

NotaPythonGeek

Obtaining 2 or more coefficients from defined equation using regression methods

I'm looking to run this code that enables to solve for the x number of unknowns (c_10, c_01, c_11 etc.) just from plotting the graph.

Some background on the equation: Mooney-Rivlin model (1940) with P1 = c_10[(2*λ+λ**2)-3]+c_01[(λ**-2+2*λ)-3].

P1 (or known as P) and lambda are data pre-defined in numerical terms in the table below (sheet ExperimentData of experimental_data1.xlsx):

λ       P
1.00    0.00
1.01    0.03
1.12    0.14
1.24    0.23
1.39    0.32
1.61    0.41
1.89    0.50
2.17    0.58
2.42    0.67
3.01    0.85
3.58    1.04
4.03    1.21
4.76    1.58
5.36    1.94
5.76    2.29
6.16    2.67
6.40    3.02
6.62    3.39
6.87    3.75
7.05    4.12
7.16    4.47
7.27    4.85
7.43    5.21
7.50    5.57
7.61    6.30

I have tried obtaining coefficients using Linear regression. However, to my knowledge, random forest is not able to obtain multiple coefficients using

reg.coef_

Tried SVR with

reg.dual_coef_

However keeps obtaining error

ValueError: not enough values to unpack (expected 2, got 1)

Code below:

data = pd.read_excel('experimental_data.xlsx', sheet_name='ExperimentData')
X_s = [[(2*λ+λ**2)-3, (λ**-2+2*λ)-3] for λ in data['λ']]
y_s = data['P']

svr = SVR()
svr.fit(X_s, y_s)

c_01, c_10 = svr.dual_coef_

And for future proofing this method, if lets say there are more than 2 coefficients, are there other methods apart from Linear Regression?

For example, referring to Ishihara model (1951) where P1 = {2*c_10 + 4*c_20*c_01[(2*λ**-1+λ**2) - 3]*[(λ**-2 + 2*λ) - 3] + c_20 * c_01 * (λ**-1) * [(2*λ**-1 + λ**2) - 3]**2}*{λ - λ**-2}

Any comments is greatly appreciated!

python

math

regression

physics

coefficients

0 Answers

Your Answer

Accepted video resources