Introduction To ML Linear Regression
Introduction To ML Linear Regression
Linear Regression
Linear Relations between two variables
Mpg
Weight
2
Data Source: StatLib (http://lib.stat.cmu.edu/datasets/)
Which one has a stronger relationship?
3
Measures of Association
4
• Covariance:
• The covariance between a variable and itself is the variance of the variable.
• Correlation
• The correlation between X and Y is the same as the correlation between Y and X.
6
7
Source: Wikipedia
Salaries and Expenses
• Next: If a car’s weight is 4000, what would we expect its Mpg to be?
Weight
8
How easy is it to fit a straight line?
Mpg
Weight
9
One possibility that makes sense...
10
Least Squares Estimation
• Note that:
• Residual: The difference between the actual and fitted values of the response variable.
• Least Squares line is the one that minimizes the sum of the
squared residuals.
11
So...
12
How good is our regression fit?
13
Measures of Regression Fit
14
Measures of Regression Fit
• Coefficient of determination
P
e2i
R2 = 1 P
(yi ȳ)2
16
Data Source: StatLib (http://lib.stat.cmu.edu/datasets/)
Standard Error and Adjusted R2
• Adjusted R2
17
Pros and Cons
• Advantages
• Disadvantages
18