Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 4cfea4b

Browse files
Hao Wufacebook-github-bot
authored andcommitted
multi-label soft metrics (#754)
Summary: Pull Request resolved: #754 compute multi-label soft metrics Reviewed By: liaimi Differential Revision: D16114819 fbshipit-source-id: 93a26cab8a3ea09fd2e54dde3aae495054fc5779
1 parent 0a77e34 commit 4cfea4b

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

pytext/metrics/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,8 @@ def compute_multi_label_soft_metrics(
629629
y_true = []
630630
y_score = []
631631
for label_scores, _, expected in predictions:
632-
for expected_label in expected:
633-
if expected_label < 0:
634-
break
635-
y_true.append(expected_label == i)
636-
y_score.append(label_scores[i])
632+
y_true.append(i in expected)
633+
y_score.append(label_scores[i])
637634
y_true_sorted, y_score_sorted = sort_by_score(y_true, y_score)
638635
ap = average_precision_score(y_true_sorted, y_score_sorted)
639636
recall_at_precision_dict = recall_at_precision(

pytext/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _set_fp16(use_fp16: bool) -> None:
5555

5656

5757
def _set_distributed(
58-
rank: int, world_size: int, dist_init_url: str, device_id: int,
58+
rank: int, world_size: int, dist_init_url: str, device_id: int
5959
) -> None:
6060
if dist_init_url and world_size > 1:
6161
distributed.dist_init(rank, world_size, dist_init_url, device_id)

0 commit comments

Comments
 (0)