title: How to get the feature names in a different pipeline in sklearn in python
body: <p>I am using the following code (<a href="https://scikit-learn.org/stable/auto_examples/compose/plot_feature_union.html#sphx-glr-auto-examples-compose-plot-feature-union-py" rel="nofollow noreferrer">source</a>) to concatenate multiple feature extraction methods.</p>
  
  <pre><code>from sklearn.pipeline import Pipeline, FeatureUnion
  from sklearn.model_selection import GridSearchCV
  from sklearn.svm import SVC
  from sklearn.datasets import load_iris
  from sklearn.decomposition import PCA
  from sklearn.feature_selection import SelectKBest
  
  iris = load_iris()
  
  X, y = iris.data, iris.target
  
  pca = PCA(n_components=2)
  selection = SelectKBest(k=1)
  
  # Build estimator from PCA and Univariate selection:
  combined_features = FeatureUnion([("pca", pca), ("univ_select", selection)])
  
  # Use combined features to transform dataset:
  X_features = combined_features.fit(X, y).transform(X)
  print("Combined space has", X_features.shape[1], "features")
  
  svm = SVC(kernel="linear")
  
  # Do grid search over k, n_components and C:
  pipeline = Pipeline([("features", combined_features), ("svm", svm)])
  
  param_grid = dict(features__pca__n_components=[1, 2, 3],
                    features__univ_select__k=[1, 2],
                    svm__C=[0.1, 1, 10])
  
  grid_search = GridSearchCV(pipeline, param_grid=param_grid, cv=5, verbose=10)
  grid_search.fit(X, y)
  print(grid_search.best_estimator_)
  </code></pre>
  
  <p>I want to get the names of the selected features from the above code.</p>
  
  <p>For that, I used, <code>grid_search.best_estimator_.support_</code>. However, this returned an error saying:</p>
  
  <pre><code>AttributeError: 'Pipeline' object has no attribute 'support_'
  </code></pre>
  
  <p>Is there a way to get the <strong>selected feature names</strong> as shown in the above code in sklearn in python?</p>
  
  <p>I am happy to provide more details if needed.</p>