.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/vision/model_evaluation/plot_confusion_matrix.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_checks_gallery_vision_model_evaluation_plot_confusion_matrix.py: .. _plot_vision_confusion_matrix: Confusion Matrix **************** This notebooks provides an overview for using and understanding the confusion matrix check. **Structure:** * `What is the purpose of the check? <#what-is-the-purpose-of-the-check>`__ * `Generate data & model <#generate-data-and-model>`__ * `Run the check <#run-the-check>`__ What is the purpose of the check? ================================= The confusion matrix check outputs a confusion matrix for both classification problems and object detection problems. In object detection problems, some predictions do not overlap on any label and can be classified as not found in the confusion matrix. .. GENERATED FROM PYTHON SOURCE LINES 24-28 Generate Data and Model ------------------------ We generate a sample dataset of 128 images from the `COCO dataset `__, and using the `YOLOv5 model `__. .. GENERATED FROM PYTHON SOURCE LINES 28-34 .. code-block:: default from deepchecks.vision.datasets.detection import coco yolo = coco.load_model(pretrained=True) train_ds = coco.load_dataset(object_type='VisionData') .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading: "https://github.com/ultralytics/yolov5/archive/v6.1.zip" to /home/runner/.cache/torch/hub/v6.1.zip Downloading https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s.pt to yolov5s.pt... 0%| | 0.00/14.1M [00:00 Confusion Matrix

.. GENERATED FROM PYTHON SOURCE LINES 45-46 If you have a GPU, you can speed up this check by calling: .. GENERATED FROM PYTHON SOURCE LINES 46-49 .. code-block:: default # check.run(train_ds, yolo, device=) .. GENERATED FROM PYTHON SOURCE LINES 50-51 To display the results in an IDE like PyCharm, you can use the following code: .. GENERATED FROM PYTHON SOURCE LINES 51-53 .. code-block:: default # result.show_in_window() .. GENERATED FROM PYTHON SOURCE LINES 54-55 The result will be displayed in a new window. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 22.110 seconds) .. _sphx_glr_download_checks_gallery_vision_model_evaluation_plot_confusion_matrix.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_confusion_matrix.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_confusion_matrix.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_