A very big hello and welcome back.
In the previous lesson, we learned about loss, root, mean squared error and mean absolute error.
In this lesson, we are going to learn about R-squared and adjusted R-squared scores.
R-squared is used to determine the strength of correlation between the features and the target, or
in simple terms, it's let us know how good a regression model is when compared to the mean.
The formula for R-squared is square equal to one minus s are by Estie here as R is the sum of squares
of residuals.
It is the sum of the squares of the difference between the actual value Y and the predicted value y
hat and S.
T is the total sum of squares.
That is the sum of the squares of the difference between the actual observed value y and the average
of the observed Y value.
Now let us understand our square with the help of an example here.
I have selected one feature number of rooms to predict the price of the house.
We see the trend that if the number of rooms are increasing, the price of the house is increasing as
well.
VI are our actual values and y hat are our predictions and y bar is the mean of actual values.
From the looks of it, we realize that our prediction line fits the data, but we also need to find
how well does the model fit or is it at least better than the mean?
Here we have considered values for vi y hat y bar.
We also find residual that is y minus Y had to calculate the S and deviation from mean.
That is why minus y bar to calculate the mean value is the mean of actual VI, which is seven seven
zero five in this table.
Now let us substitute these values to calculate SSR and SD, as we have calculated, both are in essence
estimate.
Now we can push them in the R-squared formula where we get our square equal to one minus S.R. by S-T.
That is zero point eight eight five five.
This means the relationship between house price and number of rooms explains eighty eight point five
five percent variation of the data.
All square will be one if s are equal to zero.
That is VI is equal to Y hat, which means the predictions are exactly the same as the actual values.
Now this can never happen as it is impossible to predict continuous values.
Precisely.
Our square will be zero if SSR is equal to S-T.
That is why that is equal to Y bar, which means if our predictions are no better than the mean, then
our model has performed poorly.
All square can also be negative.
This happens when SSR is greater than Estie, which means our predictions are not following the trend
of value, but in turn they are following the reverse trend.
Here we see that the predictions y hat is following a different trend compared to the actual values
y.
But there is a flaw with R-squared.
R-squared keeps increasing by adding more number of features and this property is called R-squared inflation
or increasing nature of our square.
To solve this problem, we have adjusted our square adjusted R Square has the capability to decrease
with the addition of less significant variables, thus resulting in a more reliable and accurate evaluation.
The formula for adjusted R-squared is adjusted.
R Square is equal to one minus one minus R squared multiplied with and minus one by N minus K minus
one here.
R-squared is R-squared scored and is equal to the number of records.
And key is the number of features having key in the denominator, having a large key that is more number
of features would increase the value after minus, which in turn would penalize the whole metric.
To summarize are just it all square is a better.
Evaluate and calculate the variables more efficiently that are squared, and now it's time for a quick
recap in this lesson we learnt about R-squared, why R-squared may not be a good metric and how just
to ask it in the next lesson, we are going to put all the N and scoring functions.
Dolgan AP Basilone.