From face90f7aea487e8337f3b0ba3ae0535b212bdd0 Mon Sep 17 00:00:00 2001 From: jason_cv Date: Tue, 14 Apr 2020 17:42:38 -0500 Subject: [PATCH] =?UTF-8?q?Ejemplo=20de=20regresi=C3=B3n=20polinomial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- regresionpolinomial.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 regresionpolinomial.py diff --git a/regresionpolinomial.py b/regresionpolinomial.py new file mode 100644 index 0000000..c4234e2 --- /dev/null +++ b/regresionpolinomial.py @@ -0,0 +1,20 @@ +import numpy as np +import matplotlib.pyplot as plt +from sklearn.preprocessing import PolynomialFeatures +from sklearn.linear_model import LinearRegression +############################### +#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_poly = poly_features.fit_transform(X) +lin_reg = LinearRegression() +lin_reg.fit(X_poly, y) +yout=lin_reg.predict(X_poly) +plt.plot(X,yout,"*") +plt.show() \ No newline at end of file