@@ -193,9 +193,8 @@ def gaussian_log_probability(
193193 """
194194 if variance <= 0 :
195195 raise ValueError ("Variance must be positive." )
196- return (
197- - 0.5 * math .log (2 * math .pi * variance )
198- - 0.5 * ((feature_value - mean ) ** 2 / variance )
196+ return - 0.5 * math .log (2 * math .pi * variance ) - 0.5 * (
197+ (feature_value - mean ) ** 2 / variance
199198 )
200199
201200
@@ -228,9 +227,7 @@ def predict_single(
228227
229228 for class_label , feature_summaries in summaries .items ():
230229 score = priors [class_label ]
231- for feature_value , (mean , variance ) in zip (
232- feature_vector , feature_summaries
233- ):
230+ for feature_value , (mean , variance ) in zip (feature_vector , feature_summaries ):
234231 score += gaussian_log_probability (feature_value , mean , variance )
235232 if score > best_score :
236233 best_score = score
@@ -307,9 +304,7 @@ def accuracy(predictions: list[int], actual: list[int]) -> float:
307304 if not predictions :
308305 raise ValueError ("Inputs must not be empty." )
309306 if len (predictions ) != len (actual ):
310- raise ValueError (
311- "Predictions and actual labels must have the same length."
312- )
307+ raise ValueError ("Predictions and actual labels must have the same length." )
313308 correct = sum (p == a for p , a in zip (predictions , actual ))
314309 return correct / len (actual )
315310
0 commit comments