MATLAB: How to visualize the contributive factors and distribution of coefficients in the “coeff” matrix output by “pca”

Statistics and Machine Learning Toolbox

How can I visualize the distribution of weights/coefficients in the "coeff" matrix output by "pca" (used for Principal Component Analysis)? I have a large number of features / predictor variables, and I am interested in visualizing the contributive features for the principal components. For instance, can I visualize this via a heatmap?

Best Answer

One possible approach is to provide the "coeff" matrix as the input to the "heatmap" function. The x-axis would represent the principal components, while the y-axis would represent the predictor variables. The heatmap would indicate the distribution of the contributive features for each principal component.
In order to illustrate, here is an example:
load hald
coeff = pca(ingredients)
heatmap(coeff,'XLabel','Principal Components','YLabel','Variables');
For more details about the "heatmap" function, you can refer to the following link:
Note that the "biplot" function provides another way to visualize the magnitude and sign of each variable's contribution to the first two or three principal components: