-1

I am trying to obtain which features in my dataset affects the principal components, and trying to observe how my data fitted in my Kernel PCA algorithm. I tried to use X_transformed_fit_ attribute which exists in documentary but I got this error: AttributeError: 'KernelPCA' object has no attribute 'X_transformed_fit_'

My code for KPCA is below:

from sklearn.decomposition import KernelPCA
kpca = KernelPCA(n_components = 2, kernel = 'cosine', fit_inverse_transform = False)
X = kpca.fit_transform(X)
kpca.X_transformed_fit_

If it is not the way I can obtain how to interpret the composition of my KPCA, then how am I going to understand that these principal components are constructed? The reason why I am investigating is that I will continue to this process with clustering algorithm implementation (K-means, agglomerative HC), and I want to understand the characters of my distinct clusters that will be derived from the algorithms at the end (by understanding the structure of the principal components).

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
Beg
  • 405
  • 1
  • 5
  • 18

1 Answers1

0

The attribute X_transformed_fit_ is only available when you set the parameter fit_inverse_transform to True.

Try:

kpca = KernelPCA(n_components = 2, kernel = 'cosine', fit_inverse_transform = True)
X = kpca.fit_transform(X)
kpca.X_transformed_fit_
Vivek Kumar
  • 35,217
  • 8
  • 109
  • 132
  • could you tell what is the exact purpose of assigning X_transformed_fit_ at kpca? because it changes the computation results of eigenvalues and eigenvectors a lot. @Vivek Kumar – Beg May 25 '18 at 06:16
  • @Beg I'm sorry I dont know that. You may ask this on scikit-learn mailing list – Vivek Kumar May 25 '18 at 06:17