Skip to content

Instantly share code, notes, and snippets.

Created November 23, 2020 08:09
What would you like to do?
3 ways to do dimensional reduction techniques in Scikit-learn
import matplotlib.pyplot as pltf
fig = plt.figure(figsize=(8, 4))
plt.imshow(pca.components_, interpolation = 'none', cmap = 'plasma')
feature_names = list(data.feature_names)
plt.gca().set_xticks(np.arange(-.5, len(feature_names)));
plt.gca().set_yticks(np.arange(0.5, 2));
plt.gca().set_xticklabels(feature_names, rotation=90, ha='left', fontsize=12);
plt.gca().set_yticklabels(['First PC', 'Second PC'], va='bottom', fontsize=12);
plt.colorbar(orientation='horizontal', ticks=[pca.components_.min(), 0,
pca.components_.max()], pad=0.65);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment