Ridge Regression Loss Function
Linear Models DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Implement Ridge Regression Loss Function, L2 Penalty, Mean Squared Error, Weight Decay, Frobenius Norm, Bias-Variance Tradeoff, Linear Algebra, Statistical Learning, Optimization Theory, Numerical Computing, Supervised Learning, Regularization Techniques, Loss Function Design, Linear Regression Models, Vectorized Operations, Model Complexity Control.
Write a Python function ridge loss that implements the Ridge Regression loss function. The function should take a 2D numpy array X representing the feature matrix, a 1D numpy array w representing the coefficients, a 1D numpy array y true representing the true labels, and a float alpha representing the regularization parameter. The function should return the Ridge loss, which combines the Mean Squared Error (MSE) and a regularization term.