@@ -62,7 +62,9 @@ def fit(self, features: np.ndarray, target: np.ndarray) -> None:
62
62
>>> rr.theta is not None
63
63
True
64
64
"""
65
- features_scaled , mean , std = self .feature_scaling (features ) # Normalize features
65
+ features_scaled , mean , std = self .feature_scaling (
66
+ features
67
+ ) # Normalize features
66
68
m , n = features_scaled .shape
67
69
self .theta = np .zeros (n ) # Initialize weights to zeros
68
70
@@ -90,9 +92,11 @@ def predict(self, features: np.ndarray) -> np.ndarray:
90
92
>>> predictions.shape == target.shape
91
93
True
92
94
"""
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
94
98
return features_scaled .dot (self .theta )
95
-
99
+
96
100
def compute_cost (self , features : np .ndarray , target : np .ndarray ) -> float :
97
101
"""
98
102
Compute the cost function with regularization.
@@ -110,7 +114,9 @@ def compute_cost(self, features: np.ndarray, target: np.ndarray) -> float:
110
114
>>> isinstance(cost, float)
111
115
True
112
116
"""
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
114
120
m = len (target )
115
121
predictions = features_scaled .dot (self .theta )
116
122
cost = (1 / (2 * m )) * np .sum ((predictions - target ) ** 2 ) + (
0 commit comments