There is a polynomial of degree 11 (its some X and Y data) and the following sequence of steps: pipeline (with PolynomialFeatures and StandardScaler) and the regularisation itself – it is done at different alpha. The best estimate came out for models[4], its coefficients (models[4].coef_) are in coefs[4].
Here is what is there:
array([[[17.98583557, -5.87696835, 15.2183848 , -2.18032083, 9.92964021,
-0.10494066, 6.6073722 , 0.93833414, 4.59678556, 1.37196651,
3.33868014]])
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler, PolynomialFeatures
pipe = make_pipeline(PolynomialFeatures(11, include_bias=False),
StandardScaler())
pipe.fit(x_train)
t_x_train, t_x_test = pipe.transform(x_train), pipe.transform(x_test)
...
alphas = list(np.logspace(-4, 4, 9))
from sklearn.linear_model import Ridge
models = []
coefs = []
for alpha in alphas:
m_r = Ridge(alpha=alpha).fit(t_x_train, y_train)
models.append(m_r)
coefs.append(m_r.coef_)
print(coefs[4])
but no matter how I tried to make a polynomial with these coefficients (17.985x^11 – 5.876x^10 + … or 17.985x – 5.876x^2 + …) – these are all the wrong polynomials, they are very different from the original data. I can’t figure out what to do about this and where I can get the correct coefficients to determine the polynomial itself.
Caddi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.