In [1]:
import seaborn as sns
%matplotlib inline
flights = sns.load_dataset('flights')
tips = sns.load_dataset('tips')
clustermap¶
The clustermap uses hierarchal clustering to produce a clustered version of the heatmap. For example:
In [2]:
fpt = flights.pivot_table(values='passengers',index='month',columns='year')
sns.heatmap(fpt)
Out[2]:
In [7]:
sns.clustermap(fpt)
Out[7]:
Notice now how the years and months are no longer in order, instead they are grouped by similarity in value (passenger count). That means we can begin to infer things from this plot, such as August and July being similar (makes sense, since they are both summer travel months)
In [6]:
# More options to get the information a little clearer like normalization
sns.clustermap(fpt,cmap='coolwarm',standard_scale=1)
Out[6]:
No comments:
Post a Comment