Skip to content

Commit 366932a

Browse files
committed
add_data metadata change
1 parent 25a1eee commit 366932a

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/valor_lite/classification/evaluator.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ def _create_rocauc_intermediate(
174174
sink=self._intermediate_writer,
175175
batch_size=batch_size,
176176
sorting=[
177-
("score", "descending"),
177+
("pd_score", "descending"),
178178
# ("pd_label_id", "ascending"),
179179
("match", "ascending"),
180180
],
181181
columns=[
182182
"pd_label_id",
183-
"score",
183+
"pd_score",
184184
"match",
185185
],
186186
)
@@ -194,7 +194,7 @@ def _create_rocauc_intermediate(
194194
for tbl in intermediate.iterate_tables():
195195
pd_label_ids = tbl["pd_label_id"].to_numpy()
196196
tps = tbl["match"].to_numpy()
197-
scores = tbl["score"].to_numpy()
197+
scores = tbl["pd_score"].to_numpy()
198198
fps = ~tps
199199

200200
for idx in index_to_label.keys():
@@ -286,7 +286,7 @@ def finalize(
286286
# sort in-place and locally
287287
self._writer.sort_by(
288288
[
289-
("score", "descending"),
289+
("pd_score", "descending"),
290290
("datum_id", "ascending"),
291291
("gt_label_id", "ascending"),
292292
("pd_label_id", "ascending"),
@@ -497,8 +497,8 @@ def iterate_values(self):
497497
"datum_id",
498498
"gt_label_id",
499499
"pd_label_id",
500-
"score",
501-
"winner",
500+
"pd_score",
501+
"pd_winner",
502502
"match",
503503
]
504504
for tbl in self._reader.iterate_tables(columns=columns):
@@ -512,8 +512,8 @@ def iterate_values(self):
512512
]
513513
]
514514
)
515-
scores = tbl["score"].to_numpy()
516-
winners = tbl["winner"].to_numpy()
515+
scores = tbl["pd_score"].to_numpy()
516+
winners = tbl["pd_winner"].to_numpy()
517517
matches = tbl["match"].to_numpy()
518518
yield ids, scores, winners, matches
519519

@@ -529,8 +529,8 @@ def iterate_values_with_tables(self):
529529
]
530530
]
531531
)
532-
scores = tbl["score"].to_numpy()
533-
winners = tbl["winner"].to_numpy()
532+
scores = tbl["pd_score"].to_numpy()
533+
winners = tbl["pd_winner"].to_numpy()
534534
matches = tbl["match"].to_numpy()
535535
yield ids, scores, winners, matches, tbl
536536

src/valor_lite/classification/loader.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,20 @@ def add_data(
7474
pidx = self._add_label(plabel)
7575
rows.append(
7676
{
77+
# metadata
78+
**datum_metadata,
7779
# datum
7880
"datum_uid": classification.uid,
7981
"datum_id": self._datum_count,
80-
**datum_metadata,
8182
# groundtruth
8283
"gt_label": classification.groundtruth,
8384
"gt_label_id": gidx,
8485
# prediction
8586
"pd_label": plabel,
8687
"pd_label_id": pidx,
88+
"pd_score": float(score),
89+
"pd_winner": max_score_idx == idx,
8790
# pair
88-
"score": float(score),
89-
"winner": max_score_idx == idx,
9091
"match": (gidx == pidx) and pidx >= 0,
9192
}
9293
)

src/valor_lite/classification/shared.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def generate_schema(
4545
# prediction
4646
("pd_label", pa.string()),
4747
("pd_label_id", pa.int64()),
48+
("pd_score", pa.float64()),
49+
("pd_winner", pa.bool_()),
4850
# pair
49-
("score", pa.float64()),
50-
("winner", pa.bool_()),
5151
("match", pa.bool_()),
5252
]
5353

@@ -65,7 +65,7 @@ def generate_intermediate_schema() -> pa.Schema:
6565
return pa.schema(
6666
[
6767
("pd_label_id", pa.int64()),
68-
("score", pa.float64()),
68+
("pd_score", pa.float64()),
6969
("match", pa.bool_()),
7070
]
7171
)

0 commit comments

Comments
 (0)