@@ -211,7 +211,12 @@ def _recall_macro(y_true: np.ndarray, y_pred: np.ndarray):
211
211
return _compute_macro (y_true , y_pred , _recall_micro )
212
212
213
213
214
- def f1 (y_true : np .ndarray , y_pred : np .ndarray , average : str = "micro" , zero_division : str = "warn" ):
214
+ def f1 (
215
+ y_true : np .ndarray ,
216
+ y_pred : np .ndarray ,
217
+ average : str = "micro" ,
218
+ zero_division : str = "warn" ,
219
+ ):
215
220
r"""
216
221
Compute hierarchical f-score.
217
222
@@ -311,13 +316,19 @@ def _f_score_macro(y_true: np.ndarray, y_pred: np.ndarray, zero_division):
311
316
return _compute_macro (y_true , y_pred , _f_score_micro , zero_division )
312
317
313
318
314
- def _compute_macro (y_true : np .ndarray , y_pred : np .ndarray , _micro_function , zero_division = None ):
319
+ def _compute_macro (
320
+ y_true : np .ndarray , y_pred : np .ndarray , _micro_function , zero_division = None
321
+ ):
315
322
overall_sum = 0
316
323
for ground_truth , prediction in zip (y_true , y_pred ):
317
324
if zero_division :
318
- sample_score = _micro_function (np .array ([ground_truth ]), np .array ([prediction ]), zero_division )
325
+ sample_score = _micro_function (
326
+ np .array ([ground_truth ]), np .array ([prediction ]), zero_division
327
+ )
319
328
else :
320
- sample_score = _micro_function (np .array ([ground_truth ]), np .array ([prediction ]))
329
+ sample_score = _micro_function (
330
+ np .array ([ground_truth ]), np .array ([prediction ])
331
+ )
321
332
overall_sum = overall_sum + sample_score
322
333
return overall_sum / len (y_true )
323
334
0 commit comments