Skip to content

Instantly share code, notes, and snippets.

@panicpotatoe
Created March 20, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panicpotatoe/4f11c00ed2d54cf47706a915ca67aa82 to your computer and use it in GitHub Desktop.
Save panicpotatoe/4f11c00ed2d54cf47706a915ca67aa82 to your computer and use it in GitHub Desktop.
# Fitting Linear Regression to the dataset
from sklearn.linear_model import LinearRegression
lin_reg = LinearRegression()
lin_reg.fit(X, y)
# Visualizing the Linear Regression results
def viz_linear():
plt.scatter(X, y, color='red')
plt.plot(X, lin_reg.predict(X), color='blue')
plt.title('Truth or Bluff (Linear Regression)')
plt.xlabel('Position level')
plt.ylabel('Salary')
plt.show()
return
viz_linear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment