【问题标题】:Extract best_params after running GridSearch within a pipeline在管道中运行 GridSearch 后提取 best_params
【发布时间】:2018-09-24 12:51:51
【问题描述】:

因此,我以以下方式在集成管道中运行了一个非常彻底的 GridSearch,其中包含 10 倍交叉值-

pipeline_rf = Pipeline([
('standardize', MinMaxScaler()), 
('grid_search_lr', GridSearchCV(
    RandomForestClassifier(),
    param_grid={'bootstrap': [True],
                 'max_depth': [50, 100, 150, 200],
                 'max_features': ['auto', 'sqrt'],
                 'min_samples_leaf': [1, 2, 4],
                 'min_samples_split': [2, 5, 10],
                 'n_estimators': [100, 200, 500, 1000, 1500]},
    cv=10,
    n_jobs=-1,
    scoring='roc_auc',
    verbose=2,
    refit=True
    ))
])

pipeline_rf.fit(X_train, y_train)

我应该如何提取最佳参数集?

【问题讨论】:

  • 如果答案有帮助,请接受 - 答案会占用受访者宝贵的时间...

标签: python-3.x scikit-learn pipeline random-forest grid-search


【解决方案1】:

您首先需要从管道中获取gridSearchCV 对象,然后在其上调用best_params_。这可以通过以下方式完成:

pipeline_rf.named_steps['grid_search_lr'].best_params_

【讨论】:

    猜你喜欢
    • 2020-02-20
    • 1970-01-01
    • 2020-02-10
    • 2021-02-16
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2021-12-29
    相关资源
    最近更新 更多