@@ -130,6 +130,28 @@ class SelectFromModel(MetaEstimatorMixin, SelectorMixin, BaseEstimator):
130
130
131
131
threshold_ : float
132
132
The threshold value used for feature selection.
133
+
134
+ Examples
135
+ --------
136
+ >>> from sklearn.feature_selection import SelectFromModel
137
+ >>> from sklearn.linear_model import LogisticRegression
138
+ >>> X = [[ 0.87, -1.34, 0.31 ],
139
+ ... [-2.79, -0.02, -0.85 ],
140
+ ... [-1.34, -0.48, -2.55 ],
141
+ ... [ 1.92, 1.48, 0.65 ]]
142
+ >>> y = [0, 1, 0, 1]
143
+ >>> selector = SelectFromModel(estimator=LogisticRegression()).fit(X, y)
144
+ >>> selector.estimator_.coef_
145
+ array([[-0.3252302 , 0.83462377, 0.49750423]])
146
+ >>> selector.threshold_
147
+ 0.55245...
148
+ >>> selector.get_support()
149
+ array([False, True, False])
150
+ >>> selector.transform(X)
151
+ array([[-1.34],
152
+ [-0.02],
153
+ [-0.48],
154
+ [ 1.48]])
133
155
"""
134
156
def __init__ (self , estimator , threshold = None , prefit = False ,
135
157
norm_order = 1 , max_features = None ):
0 commit comments