Supervised Learning - Prediction Week 3 Challenge
Ans 1)
Kindly refer attachment for code.
Ans 2)
L1 Mean absolute error: finds the mean of the absolute difference between the predicted and actual value. It is good for data set with little or no outliers. However, it needs more complicated tools such as linear programming to calculate the gradients of the parameters.
L2 Mean squared error: Finds the mean of the square of the difference between the predicted and actual value. It is good for data set with outliers, however returns an error in different units. Due to its mathematical properties, it is easier to calculate the gradients of the parameters. The squaring means that larger mistakes result in more error than smaller mistakes, meaning that the model is punished for making larger mistakes. Finding the root of the mean squared error, i.e. using root mean square error bring the error term to match with the data set in terms of units.
Ans 3)
Root mean square error
Mean square error
Mean absolute error
Ans 4)
Learning rate is an important factor that determines how fast the function parameter approaches a nominal value. Giving a high learning rate will cause the function to overshoot beyond its lowest value and will never reach its lowest value or will oscillate before arriving at one. Giving a low learning rate will cause the function to approach the lowest value very slowly leading to a high number of iterations.
Ans 5)
Sum of squared error:
SSE = ∑(y(i) − f(x(i)))²
If the proposed equation is an nth degree polynomial
f(x) = A1 + A2 ⋅ x + A3 ⋅ x² + ...... + An ⋅ x**(n − 1)
Differentiating the SSE with each coefficient and equating it to zero will return us the value of the coefficient for which the error is minimum. Solving the multiple systems of equations we can get the value of the coefficients. This is the least square error method.
R-square:
Rsquare = SSR / SST
where SST = SSE + SSR
SSR stands for the sum of the square of the regression and is equal to the square of the difference between the value of the fitting function at the given point and the mean of the data set.
SSR = ∑(f(x(i)) − M )² , where M is the arithmetic mean of the given data set.
Ans 6)
When the dependent variable depends on only one independent variable then it is known as the linear coefficient of determination, but when it depends on multiple Independent variables then it is multiple coefficient of determination.
The Adjusted coefficient of determination is the method in which the parameters which do not contribute towards the predicted value are ignored. These parameters are called insignificant independent variables.
Adding new variables to the system will affect the R-squared value and the adjusted R-squared disregards the infinitesimally small increments and only considers the parameters which contribute to the output in a significant way.
R²adj = 1 − [((1−R²)(n−1))/n−k−1]
where n = number of data points k = number of independent variables