title: The easiest way for getting feature names after running SelectKBest in Scikit Learn
body: <p>I would like to make supervised learning.</p>
  <p>Until now I know to do supervised learning to all features.</p>
  <p>However, I would like also to conduct experiment with the K best features.</p>
  <p>I read the documentation and found the in Scikit learn there is SelectKBest method.</p>
  <p>Unfortunately, I am not sure how to create new dataframe after finding those best features:</p>
  <p>Let's assume I would like to conduct experiment with 5 best features:</p>
  <pre><code>from sklearn.feature_selection import SelectKBest, f_classif
  select_k_best_classifier = SelectKBest(score_func=f_classif, k=5).fit_transform(features_dataframe, targeted_class)
  </code></pre>
  <p>Now if I would add the next line:</p>
  <pre><code>dataframe = pd.DataFrame(select_k_best_classifier)
  </code></pre>
  <p>I will receive a new dataframe without feature names (only index starting from 0 to 4).</p>
  <p>I should replace it to:</p>
  <pre><code>dataframe = pd.DataFrame(fit_transofrmed_features, columns=features_names)
  </code></pre>
  <p>My question is how to create the features_names list??</p>
  <p>I know that I should use:</p>
  <pre><code> select_k_best_classifier.get_support()
  </code></pre>
  <p>Which returns array of boolean values.</p>
  <p>The true value in the array represent the index in the right column.</p>
  <p>How should I use this boolean array with the array of all features names I can get via the method:</p>
  <pre><code>feature_names = list(features_dataframe.columns.values)
  </code></pre>