def fit(self, X, y):
import scipy.sparse
import sklearn.feature_selection
self.preprocessor = sklearn.feature_selection.SelectPercentile(
score_func=self.score_func,
percentile=self.percentile)
# Because the pipeline guarantees that each feature is positive,
# clip all values below zero to zero
if self.score_func == sklearn.feature_selection.chi2:
if scipy.sparse.issparse(X):
X.data[X.data<0] = 0.0
else:
X[X<0] = 0.0
self.preprocessor.fit(X, y)
return self
select_percentile_classification.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录