def fit(self, X, Y, sample_weight=None):
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.feature_selection import SelectFromModel
num_features = X.shape[1]
max_features = int(
float(self.max_features) * (np.log(num_features) + 1))
# Use at most half of the features
max_features = max(1, min(int(X.shape[1] / 2), max_features))
preprocessor = ExtraTreesClassifier(
n_estimators=self.n_estimators, criterion=self.criterion,
max_depth=self.max_depth, min_samples_split=self.min_samples_split,
min_samples_leaf=self.min_samples_leaf, bootstrap=self.bootstrap,
max_features=max_features, max_leaf_nodes=self.max_leaf_nodes,
oob_score=self.oob_score, n_jobs=self.n_jobs, verbose=self.verbose,
random_state=self.random_state, class_weight=self.class_weight
)
preprocessor.fit(X, Y, sample_weight=sample_weight)
self.preprocessor = SelectFromModel(preprocessor, prefit=True)
return self
extra_trees_preproc_for_classification.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录