In [1]:
print(__doc__)

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

from sklearn.preprocessing import label_binarize
from sklearn.metrics import confusion_matrix

%matplotlib inline

dir = '/Users/chanjinpark/GitHub/NRFAnalysis/data/temp/'

df = pd.read_csv(dir + 'metrics-confusionmatrix.csv', encoding="utf-8")


Automatically created module for IPython interactive environment

In [2]:
import matplotlib
matplotlib.rc('font', family='AppleGothic')

def plot_confusion_matrix(cm, title='Confusion matrix', cmap=plt.cm.Blues):
    plt.figure(figsize=(12, 12))
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(cm.columns))
    plt.xticks(tick_marks, cm.columns, rotation=45)
    plt.yticks(tick_marks, cm.index)
#    plt.tight_layout()
    plt.ylabel('True label')
    plt.xlabel('Predicted label')
    plt.savefig('cm1.png', dpi=100)
    
plot_confusion_matrix(df)
plt.figure()


/usr/local/lib/python2.7/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):
Out[2]:
<matplotlib.figure.Figure at 0x10f2e6b50>
<matplotlib.figure.Figure at 0x10f2e6b50>

In [3]:
df_normalized = (df - df.mean()) / df.std()
plot_confusion_matrix(df_normalized)
plt.figure()


Out[3]:
<matplotlib.figure.Figure at 0x10b345e50>
<matplotlib.figure.Figure at 0x10b345e50>

In [8]:


In [ ]: