Find out selected features in transformed output in Feature Selection
<p>I was using the L1-based feature selection from <a href="http://scikit-learn.org/stable/modules/feature_selection.html" rel="nofollow">feature selection documentaion</a> . The transformed result gives a numpy array. Is there a way I could figure out which features got selected in the transformed output <code>X_new</code>.</p>

<pre><code>from sklearn.svm import LinearSVC
from sklearn.datasets import load_iris
from sklearn.feature_selection import SelectFromModel
import pandas as pd
iris = load_iris()
y=iris.target
X = pd.DataFrame(iris.data,columns=['sepal_length','sepal_width','petal_length','petal_width'])
print X.shape #(150,4)                                                                                                                               
lsvc = LinearSVC(C=0.01, penalty="l1", dual=False).fit(X, y)
model = SelectFromModel(lsvc, prefit=True)
X_new = model.transform(X)
print X_new.shape #(150, 3) 
</code></pre>

<p>I figured from this question <a href="http://stackoverflow.com/questions/27622175/which-features-selects-fit-transform?rq=1">Which features selects fit_transform?</a> that lsvc.coef_ would return me the complete transfromed numpy array with a few features having all <code>0's</code>.</p>

<pre><code>df=pd.DataFrame(lsvc.coef_,columns=['sepal_length','sepal_width','petal_length','petal_width'])
print df.columns[(df == 0).all()]
</code></pre>

python scikit-learn