本文主要对对应文档的内容进行简化(以代码示例为主)及汉化
对应文档位置:http://scikit-learn.org/stable/modules/feature_selection.html#feature-selection
1.13. Feature selection
feature selection 作用: 增加分类器的score ,提升分类器在高纬数据集上的表现
- 1.13.1. Removing features with low variance
-
from sklearn.feature_selection import VarianceThreshold
X = [[0, 0, 1], [0, 1, 0], [1, 0, 0], [0, 1, 1], [0, 1, 0], [0, 1, 1]]
sel = VarianceThreshold(threshold=(.8 * (1 - .8)))
sel.fit_transform(X)
array([[0, 1],
[1, 0],
[0, 0],
[1, 1],
[1, 0],
[1, 1]])
说明: VarianceThreshold
-
默认值:去除差异值为0(或者为相同值的变量)
-
VarianceThreshold(threshold=(.8 * (1 - .8))) ,例子中假设为bool型变量(取值为0,1),其参数threshold的值为方差值; 对于伯努利分布,其方差为p(1-p)=0.8*(1-0.8)
- 1.13.2. Univariate feature selection(单变量特征选择)