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

Commit

Permalink
adapt prediction workflow to new design
Browse files Browse the repository at this point in the history
Summary: the prediction workflow only supports the old design, migrate it to support the new design. since I found some recurring jobs set using the old design, I didn't completely remove the old design support, but making it rather separate so it's easy to get rid of the old design in the future.

Differential Revision: D16096788

fbshipit-source-id: 39d3606f3e76ae23e51037caac8d0652818d17cc
  • Loading branch information
Haoran Li authored and facebook-github-bot committed Jul 3, 2019
1 parent eaadfe1 commit 6a22f99
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit 6a22f99

Please sign in to comment.