CS601 - Machine Learning - Unit 1 - Regression
CS601 - Machine Learning - Unit 1 - Regression
22
Prediction: Regression Example
u Problem Statement
u Last year, five randomly selected students took a math aptitude test
before they began their statistics course. The Statistics Department has
three questions.
23
How to Find the Regression Equation
u In the table below, the xi column shows scores on the aptitude test.
Similarly, the yi column shows statistics grades.
u The last two columns show deviations scores - the difference between
the student's score and the average score on each test.
u The last two rows show sums and mean scores that we will use to
conduct the regression analysis.
24
How to Find the Regression Equation
u And for each student, we also need to compute the squares of the
deviation scores (the last two columns in the table below).
25
How to Find the Regression Equation
u And finally, for each student, we need to compute the product of the
deviation scores.
26
How to Find the Regression Equation
u The regression equation is a linear equation of the form: ŷ = b0 + b1x . To
conduct a regression analysis, we need to solve for b0 and b1.
Computations are shown below. Notice that all of our inputs for the
regression analysis come from the above three tables.
u First, we solve for the regression coefficient (b1):
b1 = Σ [ (xi - x̄)(yi - ȳ) ] / Σ [ (xi - x̄)2]
b1 = 470/730
b1 = 0.644
u Once we know the value of the regression coefficient (b1), we can solve
for the regression slope (b0):
b0 = ȳ - b1 * x̄
b0 = 77 - (0.644)(78)
b0 = 26.768
u Therefore, the regression equation is: ŷ = 26.768 + 0.644x. 27
How to Use the Regression Equation
u Once you have the regression equation, using it is a snap. Choose a value
for the independent variable (x), perform the computation, and you have
an estimated value (ŷ) for the dependent variable.
u ŷ = b0 + b1x
u ŷ = 26.768 + 0.644x = 26.768 + 0.644 * 80
u ŷ = 26.768 + 51.52 = 78.288
28
How to Use the Regression Equation
u Whenever you use a regression equation, you should ask how well the
equation fits the data. One way to assess fit is to check the coefficient of
determination, which can be computed from the following formula.
29
How to Use the Regression Equation
u Computations for the sample problem of this lesson are shown below. We
begin by computing the standard deviation of x (σx):
u σx = sqrt [ Σ ( xi - x̄ )2 / N ]
u σx = sqrt( 730/5 ) = sqrt(146) = 12.083
u Next, we find the standard deviation of y, (σy):
u σy = sqrt [ Σ ( yi - ȳ )2 / N ]
u σy = sqrt( 630/5 ) = sqrt(126) = 11.225
u And finally, we compute the coefficient of determination (R2):
u R2 = { ( 1 / N ) * Σ [ (xi - x̄) * (yi - ȳ) ] / (σx * σy ) }2
u R2 = [ ( 1/5 ) * 470 / ( 12.083 * 11.225 ) ]2
u R2 = ( 94 / 135.632 )2 = ( 0.693 )2 = 0.48
30
How to Use the Regression Equation
u A coefficient of determination equal to 0.48 indicates that about 48% of
the variation in statistics grades (the dependent variable) can be explained
by the relationship to math aptitude scores (the independent variable).
u This would be considered a good fit to the data, in the sense that it would
substantially improve an educator's ability to predict student performance
in statistics class.
31
Types of Regression
§ Linear Regression (Linear Relationship)