首页 > 解决方案 > StackingClassifier final_estimator 网格搜索

问题描述

我正在使用 StackingClassifier,将 RandomForest 和 BaggedLogisticRegression 作为第一层estimators,将 LogisticRegression 作为final_estmator. 我使用以下参数运行 RandomizedSearch:

params = {
    
    'random_forest__max_depth': [3, 7, 10],
    'random_forest__n_estimators': [100, 150],
    
    'logreg_bagged__base_estimator__max_iter': [10000],
    'logreg_bagged__base_estimator__C': [10000, 20000, 100000],
    'logreg_bagged__base_estimator__class_weight': [{0: neg, 1: pos} for neg, pos in 
                                                        [(1 - ((val + 1) * 0.01), (val + 1) * 0.01) for val in range(5)]
                                                   ],
    'final_estimator__max_iter': [10000],
    'final_estimator__C': np.logspace(-4, 4, 4),
    'final_estimator__class_weight': [{0: neg, 1: pos} for neg, pos in 
                                                        [(1 - ((val + 1) * 0.01), (val + 1) * 0.01) for val in range(5)]
                                                   ],
}

random_forest 和 logreg_bagged 参数按预期运行,但我似乎无法访问 final_estimator 参数以将它们包含在超参数调整中。有谁知道将其包含到搜索空间中的方法?

这是模型图: Model_diagram

标签: scikit-learn

解决方案


推荐阅读