Skip to content

Commit a2d07af

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 61945d0 commit a2d07af

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

machine_learning/ridge_regression.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def fit(self, features: np.ndarray, target: np.ndarray) -> None:
6262
>>> rr.theta is not None
6363
True
6464
"""
65-
features_scaled, mean, std = self.feature_scaling(features) # Normalize features
65+
features_scaled, mean, std = self.feature_scaling(
66+
features
67+
) # Normalize features
6668
m, n = features_scaled.shape
6769
self.theta = np.zeros(n) # Initialize weights to zeros
6870

@@ -90,9 +92,11 @@ def predict(self, features: np.ndarray) -> np.ndarray:
9092
>>> predictions.shape == target.shape
9193
True
9294
"""
93-
features_scaled, _, _ = self.feature_scaling(features) # Scale features using training data
95+
features_scaled, _, _ = self.feature_scaling(
96+
features
97+
) # Scale features using training data
9498
return features_scaled.dot(self.theta)
95-
99+
96100
def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
97101
"""
98102
Compute the cost function with regularization.
@@ -110,7 +114,9 @@ def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
110114
>>> isinstance(cost, float)
111115
True
112116
"""
113-
features_scaled, _, _ = self.feature_scaling(features) # Scale features using training data
117+
features_scaled, _, _ = self.feature_scaling(
118+
features
119+
) # Scale features using training data
114120
m = len(target)
115121
predictions = features_scaled.dot(self.theta)
116122
cost = (1 / (2 * m)) * np.sum((predictions - target) ** 2) + (

0 commit comments

Comments
 (0)