我有一个如下所示的sklearn管道:
Pipeline(memory=None, steps=[('feature_processor', DataProcessor()), ('classifier', GridSearchCV(cv=15, error_score='raise-deprecating', estimator=XGBClassifier(base_score=0.5, booster='gbtree', colsample_bylevel=1, colsample_bynode=1, colsample_bytree=1, gamma=0, learning_rate=0.1, max_delta_step=0,..._dispatch='2*n_jobs', refit=True, return_train_score='warn', scoring='accuracy', verbose=1)) ])
里面有一个经过训练的模型,其参数是使用GridSearchCV
优化的。该模型和其管道被保存为pickle文件。我使用pickle.load()
读取它,但现在我不知道如何访问由GridSearchCV
找到的最佳参数。
能否请有人指点我正确的方向?
如果无法通过管道的信息访问这些信息,是否有其他方法可以做到这一点?
非常感谢您的提前帮助
回答:
试试这个:
pipeline.named_steps['classifier'].best_params_