# Kernel PCA: Find most important variables for each PC

To find the most important variable for each Principal Component is easy with PCA:

With data->X and variables->variable_names

pca=PCA()
pca.fit(X)
pca_data=pca.transform(X)
n=pca.components_.shape[0]
important=[np.abs(pca.components_[i]).argmax()for i in range(n)]
important_names = [variable_names[important[i]] for i in range(n)]
important_variables= {'PC{}'.format(i+1): important_names[i] for i in range(n)}
important_variables_f= pd.DataFrame(important_variables.items())


However, how can I accomplish the same result with Kernel PCA, since it has no components_ attribute?

With PCA, you rely on the magnitude of the coefficient in the principal component vector because each of the coefficients of the PC is explicitly multiplied with features while calculating the projection. However, in Kernel PCA, the transformed vectors, $$\phi(x)$$, are never explicitly calculated; we directly get the projections. Especially, in some cases like Gaussian kernel, these vectors are infinite dimensional, and can't be stored. For finite mappings, you could try to rewrite the exact mapping and perform PCA directly on the transformed data to get which of the new features are important (based on this variance based criterion).