Skip to content

Instantly share code, notes, and snippets.

@ankurkumartech
Created January 30, 2024 11:10
# Create a scatter plot with a regression line using Matplotlib
plt.scatter(data['X'], data['Y'])
# Calculate the regression line
slope, intercept = np.polyfit(data['X'], data['Y'], 1)
# Plot the regression line
plt.plot(data['X'], slope * data['X'] + intercept, color='red', label='Regression Line')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment