Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Created November 23, 2020 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyasugano/6e17ae53b59995d93ea10bfb7d5b201d to your computer and use it in GitHub Desktop.
Save yuyasugano/6e17ae53b59995d93ea10bfb7d5b201d to your computer and use it in GitHub Desktop.
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