turicreate
turicreate copied to clipboard
Plot confusion matrix
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.
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
To help with the SFRame gymnastics, after running:
e = cls.evaluate(test)
You could do:
-
e['confusion_matrix'].sort('count', ascending=False)
-
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