Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def plot_lin_reg(regressor, X, y, resolution=100):
- max_x = X.max()
- steps = math.ceil(max_x)/resolution
- # calculate points for linear regression
- # could also just use lin_reg.predict to get the x values
- x_points = np.arange(0, max_x + steps, steps)
- c, m = regressor.intercept_, regressor.coef_
- y_points = (m * x_points) + c
- plt.plot(x_points, y_points, 'c', linewidth=2)
- plot_data(X, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement