0

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!

  • Linear Regression can work on any number of coefficients, is not limited to 1 or 2, you will just be working in a higher dimensional space. Also not sure why you are using SVR here, why not do a linear regression the same way that the folks would have done in the 40's and 50's when they developed these models? – pygri Jan 10 '22 at 07:21
  • @pygri thanks for the tips! I think the main takeaway is that apart from using just only Linear Regression, other regression methods can be used to find coefficients. This ensure no biasness and not based on the results from Linear Regression – NotaPythonGeek Jan 10 '22 at 12:46
  • It appears the problem is still the same as [your previous question](https://stackoverflow.com/questions/70591016/how-to-set-up-and-solve-for-equations-in-python/). But now I don't even understand the question you ask about this problem? – Stef Jan 10 '22 at 14:20
  • @Stef more of the second part where instead of linReg, are there other ways to find out about the coefficients? – NotaPythonGeek Jan 11 '22 at 02:11

0 Answers0