on-internet
← Community

How to set a pandas dataframe column as index when generating a loading matrix for PCA

Stack Overflow ·

I am using scikit-learn in Python to perform principal component analysis (PCA) on gene expression data. My data is loaded as a pandas dataframe, for which I can call df.head() and the df looks good. I am using scikit-learn to generate a loading matrix, but the matrix only displays a generic index, and will not accept a column name for an index. I have 1722 genes, so it is important that I obtain the loading score for each gene computationally. Here is my code for PCA: import pandas as pd from sklearn.decomposition import PCA from sklearn import preprocessing # Load the data as pandas datafram

Comments

Sign in or sign up to comment and upvote.

No comments yet.