question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extend PCA Visualizer with Component-Feature Strength

See original GitHub issue

Describe the solution you’d like

Provide an optional heatmap and color bar underneath the PCA visualizer (by shifting the lower axes) that shows the magnitude of each feature value to the component. This provides an explanation of which features are contributing the most to which component.

Is your feature request related to a problem? Please describe.

Although we have the biplot mode to plot feature strengths, they can sometimes be visually overlapping or unintelligible, particularly if there is a large number of features.

Examples

image from ios

Code to generate this:

fig, ax = plt.subplots(figsize=(8, 4))
plt.imshow(pca.components_, interpolation = 'none', cmap = 'plasma')
feature_names = list(cancer.feature_names)

ax.set_xticks(np.arange(-.5, len(feature_names)));
ax.set_yticks(np.arange(0.5, 2));
ax.set_xticklabels(feature_names, rotation=90, ha='left', fontsize=12);
ax.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);

Though we will probably want to use the pcolormesh rather than imshow as in Rank2D, ClassificationReport and ConfusionMatrix. Additionally it might be a tad nicer if the color bar was above the feature plot so that the axes names were the last thing in the chart.

Notes

This idea comes from page 55-56 of Data Science Documentation. I would be happy to include a citation to this in our documentation. (HTML version is here). @mapattacker any thoughts?

See also #476 for other updates to the PCA visualizer.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
mapattackercommented, Sep 19, 2018

nice library! The existing biplot in this package already gives feature strengths but might not be suitable for everyone, and can be difficult to visualise when there are too many features overlapping each other. this is indeed a good additional feature to add in for PCA @bbengfort .

0reactions
bbengfortcommented, Sep 4, 2019

I don’t think so - let’s close this as fixed in #884 and #937

Read more comments on GitHub >

github_iconTop Results From Across the Web

Principal Component Analysis for Visualization
In this tutorial, you will discover how to visualize data using PCA, as well as using visualization to help determining the parameter for ......
Read more >
Research on Image Feature Extraction Algorithm of the Egg ...
Independent component analysis, as an extension of PCA, focuses on the high-order ... The coagulation strength of the egg white expressed was tested...
Read more >
A Guide to Principal Component Analysis (PCA) for Machine ...
A simplified introduction to the PCA for machine learning. Principal Component Analysis (PCA) is one of the most commonly used unsupervised machine learning ......
Read more >
Principal Component Analysis for Dimensionality Reduction
Learn the concepts and mathematics behind the PCA algorithm and how to ... indicates that the features increase or decrease together, ...
Read more >
Dimensionality reduction and visualization using PCA ...
How PCA is used in visualization… ... of the points from the unit vector selected so as to increase the spread on that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found