Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Plot regression line from sklearn

# Import LinearRegression
from sklearn.linear_model import LinearRegression
# Create the regressor: reg
reg = LinearRegression()
# Create the prediction space
prediction_space = np.linspace(min(feature), max(feature)).reshape(-1,1)
# Compute predictions over the prediction space: y_pred
y_pred = reg.predict(prediction_space)
# Plot regression line
plt.plot(prediction_space, y_pred, color='  ', linewidth=3)
plt.show()
Source by campus.datacamp.com #
 
PREVIOUS NEXT
Tagged: #Plot #regression #line #sklearn
ADD COMMENT
Topic
Name
2+2 =