Python3在RFE中比Python2慢

2024-09-28 21:40:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python sklearn的新手。自从我迁移到Python3之后,我的代码开始花费更多的时间来运行RFECV。。。运行几个RFE CV的时间从5小时到近15小时。 我找到了这个链接,但我想这个案例与我的不同:Why is Python 3 is considerably slower than Python 2?

下面是一个代码示例:

for fs_method, fs_dict in fs_models.items():
    print(fs_method)
    pickle_dict[fs_method] = dict()
    pipe = pipeline_classifier(fs_dict['clf'])

for score in fs_scorers:
    print (score)
    feature_selector_cv = skf.RFECV(pipe,
                                    cv=kf,
                                    step=rfecv_step,
                                    scoring=score.replace('-', '_'),
                                    n_jobs=-1
                                    )
    feature_selector_cv.fit(X_train, y_train)

这可能是由不同版本的sklearn造成的吗


Tags: 代码inforis时间sklearnfsmethod