# How to add confusion matrix to the workspace UI ( given that i logged the metrics)?

**URL:** <https://community.wandb.ai/t/how-to-add-confusion-matrix-to-the-workspace-ui-given-that-i-logged-the-metrics/9208>\
**Category:** W&B Help\
**Tags:** sweeps, projects, wandb, beginner-friendly\
**Created:** [March 15, 2025, 6:24pm UTC](https://community.wandb.ai/t/how-to-add-confusion-matrix-to-the-workspace-ui-given-that-i-logged-the-metrics/9208 "2025-03-15T18:24:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ns24z274](https://avatars.discourse-cdn.com/v4/letter/n/da6949/32.png) [@ns24z274](https://community.wandb.ai/u/ns24z274)\
**Post date:** [March 15, 2025, 6:24pm UTC](https://community.wandb.ai/t/how-to-add-confusion-matrix-to-the-workspace-ui-given-that-i-logged-the-metrics/9208/1 "2025-03-15T18:24:54Z")

</div>

the snippet:  
\_, \_, y\_pred = nn.test(test\_img, test\_labe)  
cm = confusion\_matrix(test\_labe, y\_pred)

```
# Log confusion matrix to WandB
if args.use_wandb.lower() == "true":

    wandb.sklearn.plot_confusion_matrix(test_labe, y_pred, labels=the_labels)
    wandb.log({"confusion_matrix": wandb.plot.confusion_matrix(
        probs=None, y_true=test_labe, preds=y_pred, class_names=the_labels
    )})
    wandb.finish()

```
