Given true and predicted labels, compute a classification report:
precision, recall, f1 and support (number of true
occurrences). Undefined values (division by zero) are 0.0.macro: unweighted mean of precision, recall and f1 over labels.accuracy: fraction of exact matches.Round every float to four decimals. Return {"labels": {label: {...}}, "macro": {...}, "accuracy": x}.
Implement report. Input: y_true: list[str], y_pred: list[str]. Returns: dict.
def report(y_true, y_pred):
acc = sum(t == p for t, p in zip(y_true, y_pred)) / len(y_true)
return {"labels": {}, "macro": {}, "accuracy": acc}
Run executes the public tests. Submit grades against public and hidden tests.
Given true and predicted labels, compute a classification report:
precision, recall, f1 and support (number of true
occurrences). Undefined values (division by zero) are 0.0.macro: unweighted mean of precision, recall and f1 over labels.accuracy: fraction of exact matches.Round every float to four decimals. Return {"labels": {label: {...}}, "macro": {...}, "accuracy": x}.
Implement report. Input: y_true: list[str], y_pred: list[str]. Returns: dict.
def report(y_true, y_pred):
acc = sum(t == p for t, p in zip(y_true, y_pred)) / len(y_true)
return {"labels": {}, "macro": {}, "accuracy": acc}
Run executes the public tests. Submit grades against public and hidden tests.