.. _example_plot_confusion_matrix.py:


================
Confusion matrix
================

Example of confusion matrix usage to evaluate the quality
of the output of a classifier on the iris data set. The
diagonal elements represent the number of points for which
the predicted label is equal to the true label, while
off-diagonal elements are those that are mislabeled by the
classifier. The higher the diagonal values of the confusion
matrix the better, indicating many correct predictions.



.. image:: images/plot_confusion_matrix_001.png
    :align: center


**Script output**::

  [[13  0  0]
   [ 0 15  1]
   [ 0  0  9]]



**Python source code:** :download:`plot_confusion_matrix.py <plot_confusion_matrix.py>`

.. literalinclude:: plot_confusion_matrix.py
    :lines: 14-

**Total running time of the example:**  0.17 seconds
( 0 minutes  0.17 seconds)