From 9ea7f86ac7e4344746ff9b176817d1001269c7f2 Mon Sep 17 00:00:00 2001 From: Matteo Maragliano Date: Thu, 22 Aug 2024 09:35:49 +0200 Subject: [PATCH] Factor `2` in computations --- 02 Linear Regression/LinearRegression.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02 Linear Regression/LinearRegression.py b/02 Linear Regression/LinearRegression.py index 8b8edba..842b187 100644 --- a/02 Linear Regression/LinearRegression.py +++ b/02 Linear Regression/LinearRegression.py @@ -17,8 +17,8 @@ def fit(self, X, y): for _ in range(self.n_iters): y_pred = np.dot(X, self.weights) + self.bias - dw = (1/n_samples) * np.dot(X.T, (y_pred-y)) - db = (1/n_samples) * np.sum(y_pred-y) + dw = (1/n_samples) * 2*np.dot(X.T, (y_pred-y)) + db = (1/n_samples) * 2*np.sum(y_pred-y) self.weights = self.weights - self.lr * dw self.bias = self.bias - self.lr * db