turicreate icon indicating copy to clipboard operation
turicreate copied to clipboard

Plot confusion matrix

Open znation opened this issue 5 years ago • 2 comments

The return value of evaluate() includes confusion matrix data as SFrame. However, there is currently no easy way to visualize this data as a confusion matrix. (The schema is somewhat awkward and needs a groupby/stack/etc. in order to get the desired plot.)

Instead of requiring users to do SFrame gymnastics (and make the association that a confusion matrix is a 2d categorical histogram on top of munged evaluation data) and hide all of this behind a .plot method on the confusion matrix Python object.

znation avatar Mar 04 '19 20:03 znation

Very much looking forward to this! In the meantime, for everyone like me, who needs a solution now, here's a gist: https://gist.github.com/nerdinand/748192be1bc69d7e39e043ace5451527

nerdinand avatar Aug 05 '19 13:08 nerdinand

To help with the SFRame gymnastics, after running: e = cls.evaluate(test) You could do:

  1. e['confusion_matrix'].sort('count', ascending=False)
  2. e['confusion_matrix'][e['confusion_matrix'].apply(lambda r: r['target_label'] != r['predicted_label'])].sort('count', ascending=False)

1 - lists pairs of target-predicted labels by their popularity 2 - sorts greatest misclassifications

griko avatar Apr 27 '21 14:04 griko