Last active
December 19, 2018 17:57
-
-
Save RyotaBannai/d3667b9ce34ab91df43bcdc0000b7046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import seaborn as sns | |
sns.set() | |
sns.despine(left=True) | |
fig, axes = plt.subplots(2, 2, figsize=(15, 10), gridspec_kw=dict(hspace=.4, wspace=.3)) | |
title_settings={'fontsize':16} | |
subtitles=['Inversed samples with {} components']*3 | |
# Plot Heatmap 1 | |
ax = sns.heatmap(digits.data, cbar=False, ax=axes[0, 0]) | |
ax.set_title('Original samples', **title_settings) | |
# Plot Heatmap 2, 3, and 4 | |
plot_ind=[[0,1],[1,0],[1,1]] | |
n_components=[2,20,40] | |
for nc, title, i in zip(n_components, subtitles, plot_ind): | |
pca = PCA(n_components=nc) | |
PC = pca.fit_transform(digits.data) | |
inversed = pca.inverse_transform(PC) | |
ax = sns.heatmap(inversed, cbar=False, ax=axes[i[0],i[1]]) | |
ax.set_title(title.format(nc), **title_settings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment