Skip to content

Instantly share code, notes, and snippets.

@Manikant92
Created September 4, 2018 15:38
Show Gist options
  • Save Manikant92/30619b2889174a6f30bcc9730df34e60 to your computer and use it in GitHub Desktop.
Save Manikant92/30619b2889174a6f30bcc9730df34e60 to your computer and use it in GitHub Desktop.
#slope -logic
m = lr.coef_[0]
#constant
c = lr.intercept_
#multiply m with all input data to form a regression line- linear equation to observe whether it is the best fit or not.
regression_line = [(m*i)+c for i in x]
#scatter plot whole x and y data.
plt.scatter(x,y,color='blue')
plt.plot(x,regression_line, color='red')
plt.ylabel('Dependent/Output Variable')
plt.xlabel('Independent/Input Variable')
plt.title('Regression Line fit')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment