title: Recovering features names of explained_variance_ratio_ in PCA with sklearn
body: <p>I'm trying to recover from a PCA done with scikit-learn, <strong>which</strong> features are selected as <em>relevant</em>.</p>
  
  <p>A classic example with IRIS dataset.</p>
  
  <pre><code>import pandas as pd
  import pylab as pl
  from sklearn import datasets
  from sklearn.decomposition import PCA
  
  # load dataset
  iris = datasets.load_iris()
  df = pd.DataFrame(iris.data, columns=iris.feature_names)
  
  # normalize data
  df_norm = (df - df.mean()) / df.std()
  
  # PCA
  pca = PCA(n_components=2)
  pca.fit_transform(df_norm.values)
  print pca.explained_variance_ratio_
  </code></pre>
  
  <p>This returns</p>
  
  <pre><code>In [42]: pca.explained_variance_ratio_
  Out[42]: array([ 0.72770452,  0.23030523])
  </code></pre>
  
  <p><strong>How can I recover which two features allow these two explained variance among the dataset ?</strong>
  Said diferently, how can i get the index of this features in iris.feature_names ?</p>
  
  <pre><code>In [47]: print iris.feature_names
  ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']
  </code></pre>
  
  <p>Thanks in advance for your help.</p>