Challenge

Supervised Learning - Prediction Week 3 Challenge

1. Completed, refer attcahed file below.

2.

3. Different loss functions:

a) Mean Squared Arror (L2 Loss) : The mean squared error is the mean of the squared errors. Here error is the difference between the model-predicted value “y_hat” and the actual value “y_real”

b) Mean Absolute Error (L1 Loss) : Mean absolute error is the mean of the absolute difference between the model-predicted value and the actual value. Mean absolute error is more robust in the case of outliers because it’s not good to square the difference as it will be too huge.

c) Root mean sqaured Error: Root Mean Squared Error is the square root of Mean square error. As we are applying square root to MSE, RMSE comes down to the same unit as the target variable. The loss function of RMSE is exactly the same as MSE, we just brought down the order from 2 to 1 so that correlation can be easily done.

d) Mean Bias Error: Mean Bias Error is the exact difference between the predicted value and the actual value without any math function like absolute or square root applied to it.

4. Learning rate is very important in finding the minimum loss function by adjusting bias and intercept. As the learning rate is very low, the number of iterations will be more to reach the loss function reach at its minima and if learning rate is high, number of iteration will be less but there is chance that it may skip the minima and move in +ve direction. Therefore, it is very crusial to select the learning rate. Usually leraning rate (alpha) ranges between .001 to .1. Depends on the case by case.

5. There are multiple methods to evaluate linear regression models:

a) R sqaure/ adjusted R square:

b) mean sqaurred error/room mean sqaured error.

c) Mean absolute error

6.

R-squared = (TSS-RSS)/TSS

= Explained variation/ Total variation

= 1 – Unexplained variation/ Total variation

The R-squared statistic isn’t perfect. In fact, it suffers from a major flaw. Its value never decreases no matter the number of variables we add to our regression model. That is, even if we are adding redundant variables to the data, the value of R-squared does not decrease. It either remains the same or increases with the addition of new independent variables. This clearly does not make sense because some of the independent variables might not be useful in determining the target variable. Adjusted R-squared deals with this issue.

adjusted R2={1-[(1-R2)(n-1)/(n-k-1)]}

  • n represents the number of data points in our dataset
  • k represents the number of independent variables, and
  • R represents the R-squared values determined by the model.
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.