diff --git a/seqeval/metrics/sequence_labeling.py b/seqeval/metrics/sequence_labeling.py index 0be1203..ac56f18 100644 --- a/seqeval/metrics/sequence_labeling.py +++ b/seqeval/metrics/sequence_labeling.py @@ -286,19 +286,19 @@ def performance_measure(y_true, y_pred): >>> performance_measure(y_true, y_pred) {'TP': 3, 'FP': 3, 'FN': 1, 'TN': 4} """ - performace_dict = dict() + performance_dict = dict() if any(isinstance(s, list) for s in y_true): y_true = [item for sublist in y_true for item in sublist] y_pred = [item for sublist in y_pred for item in sublist] - performace_dict['TP'] = sum(y_t == y_p for y_t, y_p in zip(y_true, y_pred) - if ((y_t != 'O') or (y_p != 'O'))) - performace_dict['FP'] = sum(((y_t != y_p) and (y_p != 'O')) for y_t, y_p in zip(y_true, y_pred)) - performace_dict['FN'] = sum(((y_t != 'O') and (y_p == 'O')) - for y_t, y_p in zip(y_true, y_pred)) - performace_dict['TN'] = sum((y_t == y_p == 'O') - for y_t, y_p in zip(y_true, y_pred)) - - return performace_dict + performance_dict['TP'] = sum(y_t == y_p for y_t, y_p in zip(y_true, y_pred) + if ((y_t != 'O') or (y_p != 'O'))) + performance_dict['FP'] = sum(((y_t != y_p) and (y_p != 'O')) for y_t, y_p in zip(y_true, y_pred)) + performance_dict['FN'] = sum(((y_t != 'O') and (y_p == 'O')) + for y_t, y_p in zip(y_true, y_pred)) + performance_dict['TN'] = sum((y_t == y_p == 'O') + for y_t, y_p in zip(y_true, y_pred)) + + return performance_dict def classification_report(y_true, y_pred, digits=2, suffix=False):