Poly Regression
Poly Regression
print(poly_reg.score(X_train, y_train))
print(poly_reg.score(X_test, y_test))
import numpy as np
from sklearn.preprocessing import PolynomialFeatures
X = np.arange(6).reshape(3, 2)
X
• Out: array([[0, 1],
[2, 3],
[4, 5]])
poly = PolynomialFeatures(2)
poly.fit_transform(X)
• Out: array([[ 1., 0., 1., 0., 0., 1.],
[ 1., 2., 3., 4., 6., 9.],
[ 1., 4., 5., 16., 20., 25.]]) //***[1, a, b, a2(a square), ab, b2(b square)]
poly = PolynomialFeatures(interaction_only=True)
poly.fit_transform(X)
• Out: array([[ 1., 0., 1., 0.],
[ 1., 2., 3., 6.],
[ 1., 4., 5., 20.]]) //***[1, a, b, ab]