from sklearn.linear_model import Ridge from sklearn.preprocessing import PolynomialFeatures import numpy as np import matplotlib.pyplot as plt ############################### #Datos originales ############################### m = 100 X = 6 * np.random.rand(m, 1) - 3 y = 0.5 * X**2 + X + 2 + np.random.randn(m, 1) plt.plot(X,y,".") ############################### poly_features = PolynomialFeatures(degree=2, include_bias=False) X_pol = poly_features.fit_transform(X) ridge_reg = Ridge(alpha=1, solver="cholesky") ridge_reg.fit(X_pol, y) yout=ridge_reg.predict(X_pol) print(ridge_reg.predict(1.5,2)) plt.plot(X,yout,"*") plt.show()