In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
%matplotlib inline
from pandas.tools.plotting import parallel_coordinates
df = pd.read_csv('Datasets/wheat.data')
df.head(5)


Out[1]:
id area perimeter compactness length width asymmetry groove wheat_type
0 0 15.26 14.84 0.8710 5.763 3.312 2.221 5.220 kama
1 1 14.88 14.57 0.8811 5.554 3.333 1.018 4.956 kama
2 2 14.29 14.09 0.9050 5.291 3.337 2.699 4.825 kama
3 3 13.84 13.94 0.8955 5.324 3.379 2.259 4.805 kama
4 4 16.14 14.99 0.9034 5.658 3.562 1.355 5.175 kama

In [2]:
del df['id']
df.head(5)


Out[2]:
area perimeter compactness length width asymmetry groove wheat_type
0 15.26 14.84 0.8710 5.763 3.312 2.221 5.220 kama
1 14.88 14.57 0.8811 5.554 3.333 1.018 4.956 kama
2 14.29 14.09 0.9050 5.291 3.337 2.699 4.825 kama
3 13.84 13.94 0.8955 5.324 3.379 2.259 4.805 kama
4 16.14 14.99 0.9034 5.658 3.562 1.355 5.175 kama

In [3]:
df.corr()


Out[3]:
area perimeter compactness length width asymmetry groove
area 1.000000 0.994341 0.600312 0.645418 0.801616 -0.205876 0.786096
perimeter 0.994341 1.000000 0.520544 0.657490 0.783188 -0.196360 0.813256
compactness 0.600312 0.520544 1.000000 0.360060 0.756165 -0.315668 0.236184
length 0.645418 0.657490 0.360060 1.000000 0.197228 -0.102325 0.669887
width 0.801616 0.783188 0.756165 0.197228 1.000000 -0.249378 0.619865
asymmetry -0.205876 -0.196360 -0.315668 -0.102325 -0.249378 1.000000 -0.039248
groove 0.786096 0.813256 0.236184 0.669887 0.619865 -0.039248 1.000000

In [6]:
import matplotlib.pyplot as plt

plt.imshow(df.corr(), cmap=plt.cm.Blues, interpolation='nearest')
plt.colorbar()
tick_marks = [i for i in range(len(df.columns))]
plt.xticks(tick_marks, df.columns, rotation='vertical')
plt.yticks(tick_marks, df.columns)


Out[6]:
([<matplotlib.axis.YTick at 0x2519473d320>,
  <matplotlib.axis.YTick at 0x2519472cf98>,
  <matplotlib.axis.YTick at 0x251947a62b0>,
  <matplotlib.axis.YTick at 0x251947a8828>,
  <matplotlib.axis.YTick at 0x251948382e8>,
  <matplotlib.axis.YTick at 0x25194838cf8>,
  <matplotlib.axis.YTick at 0x2519483b748>,
  <matplotlib.axis.YTick at 0x2519483f198>],
 <a list of 8 Text yticklabel objects>)