below is an overview of process

Copy_of_polynomial_regression.pdf

1. Training the Linear Regression Model

from sklearn.linear_model import LinearRegression
lin_reg = LinearRegression()
lin_reg.fit(X, y)

2. Training the Polynomial Regression Model

from sklearn.preprocessing import PolynomialFeatures
poly_reg = PolynomialFeatures(degree = 4)
X_poly = poly_reg.fit_transform(X)
lin_reg_2 = LinearRegression()
lin_reg_2.fit(X_poly, y)

3. Visualising the Linear Regression Results

plt.scatter(X, y, color = 'red')
plt.plot(X, lin_reg.predict(X), color = 'blue')
plt.title('Polynomial')
plt.xlabel('Truth or Bluff (Linear Regression)')
plt.ylabel('Salary')
plt.show()

4. Visualising the Polynomial Regression Results

plt.scatter(X, y, color = 'red')
plt.plot(X, lin_reg_2.predict(X_poly), color = 'blue')
plt.title('Polynomial')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()

5. Visualising the Polynomial Regression Results (Higher Resolution and Smoother Curve)

X_grid = np.arange(min(X), max(X), 0.1)
X_grid = X_grid.reshape((len(X_grid), 1))
plt.scatter(X, y, color = 'red')
plt.plot(X_grid, lin_reg_2.predict(poly_reg.fit_transform(X_grid)), color = 'blue')
plt.title('Polynomial')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()