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 (#746)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #746

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.

Reviewed By: jingfeidu

Differential Revision: D16096788

fbshipit-source-id: 7e51a2eebb86cda6452ecd0bd2405eceac989f4d
  • Loading branch information
Haoran Li authored and facebook-github-bot committed Jul 9, 2019
1 parent a419138 commit 6b29645
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 6b29645

Please sign in to comment.