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

adapt prediction workflow to new design #746

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions pytext/task/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ class Config(NewTask.Config):
# for multi-label classification task,
# choose MultiLabelClassificationMetricReporter

@classmethod
def format_prediction(cls, predictions, scores, context, target_names):
for prediction, score in zip(predictions, scores):
score_with_name = {n: s for n, s in zip(target_names, score.tolist())}
yield {
"prediction": target_names[prediction.data],
"score": score_with_name,
}


class DocumentRegressionTask(NewTask):
class Config(NewTask.Config):
Expand Down