From 1359e5926a99e172fd3b5415398da559fa97a2f9 Mon Sep 17 00:00:00 2001 From: preethamak <167765989+preethamak@users.noreply.github.com> Date: Mon, 13 Oct 2025 23:33:18 +0530 Subject: [PATCH] Initial Commit --- 43. Ridge Regression Loss Function | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 43. Ridge Regression Loss Function diff --git a/43. Ridge Regression Loss Function b/43. Ridge Regression Loss Function new file mode 100644 index 00000000..3759098a --- /dev/null +++ b/43. Ridge Regression Loss Function @@ -0,0 +1,17 @@ +import numpy as np + +def ridge_loss(X: np.ndarray, w: np.ndarray, y_true: np.ndarray, alpha: float) -> float: + # Your code here + x = np.array(X) + w = np.array(w) + y_true = np.array(y_true) + + y_pr = x @ w + + loss = np.mean((y_pr - y_true)**2) + + reg = alpha * np.sum(w**2) + + final_loss = loss + reg + + return final_loss