K-fold Cross-Validation; Bias-Variance Trade-off; Regularized Regression
November 30, 2026
Partitioning Data for 3-fold Cross-Validation
Training Data:
The portion of data used to fit the model.
Within this set, k‑fold cross-validation is applied.
Validation Data:
Temporary splits within the training set during cross-validation, used to tune hyperparameters and assess performance.
Test Data:
A held-out dataset that is never used during model tuning.
Provides an unbiased evaluation of the final model’s performance.
Workflow:
For a prediction \(\hat{y}\), the expected test MSE can be written as
\[ \text{(Error)}^{2} = \text{(Bias)}^{2} + \text{(Variance)} + \text{(Irreducible Noise)} \]
Warning
Regularized regression can resolve the following problems:
The above situations usually happen when the model is too complex (e.g., has large or many beta variables).
We will discuss three regularized regression methods:
When variables are nearly collinear, lasso regression tends to drive one or more of them to zero.
In the regression of PM2.5, lasso regression might give zero credit to one of the two variables, \(\texttt{hms\_heavy\_days}\) and \(\texttt{hms\_medium\_plus\_days}\).
For this reason, lasso regression is often used as a form of model/variable selection.
Elastic net regression tries to find the beta parameters \(\beta_0, \beta_1, \beta_2, \,\cdots\, \beta_{p}\) for given \(\alpha\) and \(\lambda\) such that \[ f(x_i) = b_0 + b_1 x_{1,i} + b_2 x_{2,i} + \,\cdots\, + b_p x_{p,i} \] is as close as possible to \(y_i\) for all the training data by minimizing the sum of the squared error (SSE) plus a linear combination of the ridge and the lasso penalties with the \(\alpha\) parameter: \[ \begin{align} &(y_1 - f(x_1))^2 + (y_2 - f(x_2))^2 + \,\cdots\, + (y_N - f(x_N))^2 \\ &+ \alpha \times \lambda \times(| \beta_1 | + |\beta_2 | + \,\cdots\, + |\beta_{p}|)\\ &+ (1-\alpha)\times \lambda \times(\beta_1^2 + \beta_2^2 + \,\cdots\, + \beta_{p}^2) \end{align} \] where \(0 \leq \alpha \leq 1\).
When \(\alpha = 0\), this reduces to Ridge regression.
When \(\alpha = 1\), this reduces to Lasso regression.
R’s \(\texttt{glmnet}\) package uses a sparse matrix
A sparse matrix is a matrix with many zero entries
A sparse matrix is almost essential in big data analysis because of its lower storage costs and faster computation.