Skip to content

Commit 7db4bf8

Browse files
authored
Fix feature scaling variable assignment in predictions
1 parent f123b6a commit 7db4bf8

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

machine_learning/ridge_regression.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def predict(self, features: np.ndarray) -> np.ndarray:
9595
raise ValueError("Model is not trained yet. Call the `fit` method first.")
9696

9797
# Scale features using training data
98-
features_scaled, _mean, _std= self.feature_scaling(features)
98+
features_scaled, _mean, _std= self.feature_scaling(features)
9999
return features_scaled.dot(self.theta)
100100

101101
def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
@@ -118,9 +118,8 @@ def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
118118
if self.theta is None:
119119
raise ValueError("Model is not trained yet. Call the `fit` method first.")
120120

121-
features_scaled, _, _ = self.feature_scaling(
122-
features
123-
) # Scale features using training data
121+
# Scale features using training data
122+
features_scaled, _mean, _std = self.feature_scaling(features)
124123
m = len(target)
125124
predictions = features_scaled.dot(self.theta)
126125
cost = (1 / (2 * m)) * np.sum((predictions - target) ** 2) + (

0 commit comments

Comments
 (0)