Skip to content

Instantly share code, notes, and snippets.

@panicpotatoe
Last active March 19, 2021 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panicpotatoe/37b33c053213f852a9f2cbebe703904b to your computer and use it in GitHub Desktop.
Save panicpotatoe/37b33c053213f852a9f2cbebe703904b to your computer and use it in GitHub Desktop.
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures
poly_reg = PolynomialFeatures(degree=4)
X_poly = poly_reg.fit_transform(X)
pol_reg = LinearRegression()
pol_reg.fit(X_poly, y)
# Visualizing the Polymonial Regression results
def viz_polymonial():
plt.scatter(X, y, color='red')
plt.plot(X, pol_reg.predict(poly_reg.fit_transform(X)), color='blue')
plt.title('Truth or Bluff (Linear Regression)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()
return
viz_polymonial()
@MohamedNedal
Copy link

Hi, How can I get the fit coefficients to be able to write down the fit equation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment