Answers for "linear regression plot in python"

0

how to plot a linear equation in matplotlib

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-5,5,100)
y = 2*x+1
plt.plot(x, y, '-r', label='y=2x+1')
plt.title('Graph of y=2x+1')
plt.xlabel('x', color='#1C2833')
plt.ylabel('y', color='#1C2833')
plt.legend(loc='upper left')
plt.grid()
plt.show()
Posted by: Guest on December-30-2020
0

linear regression in python

from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm.fit(X, y)
Posted by: Guest on May-09-2021

Code answers related to "linear regression plot in python"

Python Answers by Framework

Browse Popular Code Answers by Language