Presentation 37
Presentation 37
'score': [75, 66, 68, 74, 78, 72, 85, 82, 90, 82,80, 88, 85, 90, 92, 94, 94, 88, 91, 96]})
#view first five rows of DataFrame
df.head()
hours score
0 1 75
1 1 66
2 1 68
3 2 74
4 2 78
Scatter plots
import matplotlib.pyplot as plt
#create scatterplot of hours vs score
plt.scatter(df.hours, df.score)
plt.title('Hours Studied vs. Exam Score')
plt.xlabel('Hours Studied')
plt.ylabel('Exam Score')
A linear regression analysis produces estimates for the slope and intercept of
Simple linear the linear equation predicting an outcome variable, y, based on values of a
regression predictor variable, x. A general form of this equation is shown below:
Y = b2 + b1 * X , Y = b2 – b1 * X
import matplotlib.pyplot as plt
coefficient
plt.title('Scatter plot of viper length
and weight')
plt.xlabel('viper length(cm)')
plt.ylabel('viper weight(g)')
Thank you