L20-22 Linear Regression
L20-22 Linear Regression
Linear Regression
• Linear regression quantifies the relationship between one or
more predictor variable(s) and one outcome variable.
• Linear regression is commonly used for predictive analysis
and modeling.
• For example, it can be used to quantify the relative impacts of
age, gender, and diet (the predictor variables) on height (the
outcome variable).
• Linear regression makes predictions for continuous/real or
numeric variables such as sales, salary, age, product
price, etc.
Linear Regression
Data:
X y
95 85
85 95
80 70
70 65
60 75
∑x=390 ∑y=385
x ̅= 78 y ̅= 77
Solution
x y X[x-mean( Y[y-mean( X2 Y2 XY
x)] y)]
95 85 17 8 289 64 136
85 95 7 18 49 324 126
80 70 2 -7 4 49 -14
70 65 -8 -12 64 144 96
60 75 -18 -7 324 49 126
∑=390 385 730 630 470
Contd..
•
2
Coefficient of Determination (R )
•
Coefficient of Determination
•
How to use Regression Equation ??
• Given X, Find out Y?
• Problem:
• X= Math Aptitude Score Y= Statistics Grade
• If X= 75, find out Y??
• Y= 26.77+0.64(75) = 74.8
• Avoid Exploration:
• Using X values for prediction outside the range for
generating Regression Equation (i.e values below
60 and above 95)
Linear Regression using Least Square
Method
Y= ax+b
Question??
• Create Regression equation using Least Square
Method for the given data points:
• {(-2,-1),(1,1),(3,2)}
Solution
X Y XY X2
-2 -1 2 4
1 1 1 1
3 2 6 9
Solution
•
Question??
• Find the Least Square Regression Line for the
given data. Also Estimate the value of y when
x=10 X Y
0 2
1 3
2 5
3 4
4 6
Regression Analysis
•
References
• http://cse.iitkgp.ac.in/~saptarshi/courses/ml2
018spring/ML-02-linear-regression.pdf
• Course material of Andrew Ng
http://cs229.stanford.edu/