Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion flair/models/multitask_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,16 @@ def evaluate( # type: ignore[override]
# Add metrics so they will be available to _publish_eval_result.
for avg_type in ("micro avg", "macro avg"):
for metric_type in ("f1-score", "precision", "recall"):
scores[(task_id, avg_type, metric_type)] = result.classification_report[avg_type][metric_type]
if result.classification_report.get(avg_type) and result.classification_report[avg_type].get(
metric_type
):
scores[(task_id, avg_type, metric_type)] = result.classification_report[avg_type][metric_type]

# The above metrics only apply to classification tasks. This adds
# regression metrics also.
for metric_type in ("mse", "mae", "pearson", "spearman"):
if result.scores.get(metric_type):
scores[(task_id, metric_type)] = result.scores[metric_type]

scores["loss"] = loss.item() / len(batch_split)

Expand Down