Machine Learning | Regression Models
January 3, 2024
Regression is a statistical approach used to model the relationship between a dependent variable and a set of independent variables. It is a supervised machine learning technique that makes predictions based on a set of features or independent variables in a dataset. Linear coefficients of each parameter and the y-intercept are approximated through training the models with a set of training data. The final model is chosen based on which model minimizes the sum of squared residuals.
Model Selection Based on Performance
- Mean squared error or ‘quality of fit’ quantifies how well the model is able to predict values based on input feature vectors. It assesses the average squared difference between the actual and estimated values. The smaller the MSE, the closer the fit is to the data indicating a better model.
Measuring Regression Model Accuracy
- Coefficient of Determination () serves as a metric in assessing the effectiveness of a fitted regression line in accurately representing the distribution of data points between a range 0 - 1.
- Sum of Squared Residuals (RSS) measures the amount of variabilty that is left unexplained after performing regression. It is calculated by taking the sum of the squared difference between the actual value minus the predicted value.
- Total Sum of Squares (TSS) measures the inherent total variance in the response () variable. Is is calculated by taking the sum of the squared difference between each individual y value minus the mean all response data points.
- measures the amount of variability in the response that is explained through regression.
- is the proportion of the variance that explained by the model. RSS aims to reduce the variance of the response variable and if it performs well then the RSS / TSS ratio will be small.
- Residual Standard Error (RSE) measures the standard deviation of the residuals providing an measure of the lack of fit of the model. It represents how much that the response will deviate from the true regression line. A good regression model will minimize the Residual Standard Error (RSE).
- n is the number of samples in the training data.
- p is the number of features or independent variables used.
Ordinary Least Squares Linear Regression
- Linear coefficients () of each parameter represent the increase or decrease in the dependent variable for each unit change in the independent variable.
- The intercept () represents the average value of the dependent variable when all independent variables are set to 0.
- The error term () represents the variation in predicting the dependent variable that cannot be explained or reduced, as it is beyond our control.
Ridge Regression
- Ridge regression is used to fit a line to our training data with a small amount of bias to prevent overfitting. In return for that small amount of bias we get a significant drop in variance resulting in a slightly worse fit Ridge regression that can provide better long-term predictions.
- Ridge regression imposes a penalty on the size of the coefficients. We minimize a penalized residual sum of squares plus . As lamda increases the penalty also increases, in order to minimize the sum of squared residuals we shrink the parameter coefficients which can only asymptotically approach zero.
- The parameter controls the amount of shrinkage: the larger the value of , the greater the amount of shrinkage and thus the coefficients become more robust to collinearity.
- Ridge regression is better when most of the independent variables are useful.
Lasso Regression
- Lasso regression is similar to Ridge regression in that it also introduces a small amount of bias into how the new line is fit to the data but in return for that small amount of bias we get a significant drop in variance in other words by starting with a slightly worse fit Lasso regression can provide better long-term predictions.
- Similar to Ridge regression, Lasso regression imposes a penalty on the size of the coefficients. The lasso coefficients minimize a penalized residual sum of squares plus . However, in contrast to Ridge regression, Lasso regression can shrink the coefficients to zero.
- Lasso Regression tends to make coefficients of less important features zero thus effectively performing feature selection.