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
10 changes: 8 additions & 2 deletions audplot/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def confusion_matrix(
*,
labels: Sequence = None,
label_aliases: dict = None,
metric: Callable = audmetric.confusion_matrix,
percentage: bool = False,
show_both: bool = False,
ax: matplotlib.axes.Axes = None,
Expand All @@ -112,6 +113,11 @@ def confusion_matrix(
labels: labels to be included in confusion matrix
label_aliases: mapping to alias names for labels
to be presented in the plot
metric: calculator of confusion matrix.
The callable is expected
to have the two arguments ``truth`` and ``prediction``,
and the keyword arguments ``labels`` and ``normalize``.
Defaults to :func:`audmetric.confusion_matrix`
percentage: if ``True`` present the confusion matrix
with percentage values instead of absolute numbers
show_both: if ``True`` and percentage is ``True``
Expand Down Expand Up @@ -169,7 +175,7 @@ def confusion_matrix(
if labels is None:
labels = audmetric.utils.infer_labels(truth, prediction)

cm = audmetric.confusion_matrix(
cm = metric(
truth,
prediction,
labels=labels,
Expand All @@ -190,7 +196,7 @@ def confusion_matrix(

# Add a second row of annotations if requested
if show_both:
cm2 = audmetric.confusion_matrix(
cm2 = metric(
truth,
prediction,
labels=labels,
Expand Down