import numpy as np import matplotlib.pyplot as plt from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LinearRegression
poly_reg = PolynomialFeatures(degree=5) # Polynomial is used to add the features to the data, degree=1 => add data * power 0, degree = 2 => add data * power 0 and data * power 1 x_poly = poly_reg.fit_transform(x_data) lin_reg = LinearRegression() lin_reg.fit(x_poly, y_data)