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
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ def calculate_lift_table(binded):


def calculate_matrix(target: pd.Series, prediction: pd.Series, labels: List[Label]) -> ConfusionMatrix:
sorted_labels = sorted(labels) # type: ignore[type-var]
# Use str() as sort key to avoid TypeError when labels contain mixed int/str types.
# This happens when string labels like '101' are coerced to int by label_key_valudator
# while other labels (e.g. 'foo') remain as strings.
sorted_labels = sorted(labels, key=str)
matrix = metrics.confusion_matrix(target, prediction, labels=sorted_labels)
return ConfusionMatrix(labels=sorted_labels, values=[row.tolist() for row in matrix])

Expand Down