Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # Fitting Polynomial Regression to the dataset
  2. from sklearn.preprocessing import PolynomialFeatures
  3. poly_reg = PolynomialFeatures(degree=4)
  4. X_poly = poly_reg.fit_transform(X)
  5. pol_reg = LinearRegression()
  6. pol_reg.fit(X_poly, y)
  7.  
  8. # Visualizing the Polymonial Regression results
  9. def viz_polymonial():
  10. plt.scatter(X, y, color='red')
  11. plt.plot(X, pol_reg.predict(poly_reg.fit_transform(X)), color='blue')
  12. plt.title('Truth or Bluff (Linear Regression)')
  13. plt.xlabel('Position level')
  14. plt.ylabel('Salary')
  15. plt.show()
  16. return
  17. viz_polymonial()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement