class sklearn.feature_selection.SelectKBest(score_func=<function f_classif>, k=10)
[source]
Select features according to the k highest scores.
Read more in the User Guide.
Parameters: 


Attributes: 

See also
f_classif
mutual_info_classif
chi2
f_regression
mutual_info_regression
SelectPercentile
SelectFpr
SelectFdr
SelectFwe
GenericUnivariateSelect
Ties between features with equal scores will be broken in an unspecified way.
>>> from sklearn.datasets import load_digits >>> from sklearn.feature_selection import SelectKBest, chi2 >>> X, y = load_digits(return_X_y=True) >>> X.shape (1797, 64) >>> X_new = SelectKBest(chi2, k=20).fit_transform(X, y) >>> X_new.shape (1797, 20)
fit (X, y)  Run score function on (X, y) and get the appropriate features. 
fit_transform (X[, y])  Fit to data, then transform it. 
get_params ([deep])  Get parameters for this estimator. 
get_support ([indices])  Get a mask, or integer index, of the features selected 
inverse_transform (X)  Reverse the transformation operation 
set_params (**params)  Set the parameters of this estimator. 
transform (X)  Reduce X to the selected features. 
__init__(score_func=<function f_classif>, k=10)
[source]
fit(X, y)
[source]
Run score function on (X, y) and get the appropriate features.
Parameters: 


Returns: 

fit_transform(X, y=None, **fit_params)
[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: 


Returns: 

get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: 


Returns: 

get_support(indices=False)
[source]
Get a mask, or integer index, of the features selected
Parameters: 


Returns: 

inverse_transform(X)
[source]
Reverse the transformation operation
Parameters: 


Returns: 

set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: 


transform(X)
[source]
Reduce X to the selected features.
Parameters: 


Returns: 

sklearn.feature_selection.SelectKBest
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.feature_selection.SelectKBest.html