程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

使用GridsearchCV提取MLPRegressor属性(n_iter_)以获取管道中的最佳模型?

发布于2020-05-11 03:42     阅读(1638)     评论(0)     点赞(2)     收藏(5)


GridsearchCV使用了管道,并希望提取n_iter_管道组件(MLPRegressor)的一个属性(以获取最佳模型。

我正在使用Python 3.0。

创建管道

pipeline_steps = [('scaler', StandardScaler()), ('MLPR', MLPRegressor(solver='lbfgs', early_stopping=True, validation_fraction=0.1, max_iter=10000))]

MLPR_parameters = {'MLPR__hidden_layer_sizes':[(50,), (100,), (50,50)], 'MLPR__alpha':[0.001, 10, 1000]}

MLPR_pipeline = Pipeline(pipeline_steps)

gridCV_MLPR = GridSearchCV(MLPR_pipeline, MLPR_parameters, cv=kfold)
gridCV_MLPR.fit(X_train, y_train)

当我想用提取最佳模型时gridCV_GBR.best_params_,我只有GridsearchCV的结果:

{'MLPR__alpha': 0.001, 'MLPR__hidden_layer_sizes': (50,)}

但我想让的最佳模型使用MLPRegressor的迭代次数gridCV_MLPR

如何通过GridsearhCV 使用n_iter_MLPRegressor()管道设计属性


解决方案


谢谢你的帮助,

我找到了解决方案:

gridCV_MLPR.best_estimator_.named_steps['MLPR'].n_iter_

由于gridCV_MLPR.best_estimator_是管道,我们需要使用选择MLPRegressor参数.named_steps['MLPR']

非常感谢您的非常非常快速的回答...



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接:https://www.pythonheidong.com/blog/article/361850/6f211cced1edcd6997eb/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

2 0
收藏该文
已收藏

评论内容:(最多支持255个字符)