I would like to calculate the cos2 of variables and individuals in Sklearn, like the FactoMineR package does in R. Is there an alternative in pyhton?
In R with FactoMineR I do something like this
pca_exp = PCA(df)
pca_exp[["ind"]][["cos2"]]
I got, something similar to this:
Dim.1 | Dim.2 |
---|---|
0.81792535 | 0.1820747 |
0.81792535 | 0.1179768 |
In scikit-learn I'm doing this:
df = pd.DataFrame()
df['Y1'] = [9,7,8,3,1,3,4,7,2,6]
df['Y2'] = [9,13,6,1,5,11,4,3,8,10]
from sklearn.decomposition import PCA
pca = PCA(2)
results_pca = pca.fit_transform(df)