Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python scikit学习:从管道中检索模型对象_Python_Scikit Learn - Fatal编程技术网

Python scikit学习:从管道中检索模型对象

Python scikit学习:从管道中检索模型对象,python,scikit-learn,Python,Scikit Learn,我有下面的管道构建,我想做的是获取在管道内部构建的随机林模型对象。rf是唯一的初始化,它没有rf.估计器 grid_params = [{'bootstrap': [True], 'min_samples_leaf': [5], 'n_estimators': [1000], 'max_features': [8], 'min_samples_split': [12], 'max_depth': [60]}] rf

我有下面的管道构建,我想做的是获取在管道内部构建的随机林模型对象。
rf
是唯一的初始化,它没有
rf.估计器

     grid_params = [{'bootstrap': [True],
      'min_samples_leaf': [5],
      'n_estimators': [1000],
      'max_features': [8],
      'min_samples_split': [12],
      'max_depth': [60]}]

     rf = RandomForestRegressor()
     grid_search = GridSearchCV(estimator=rf, param_grid=grid_params)

     pipe = PipelineRF(
         [
             ('grid', grid_search)
         ]
     )
     _ = StratifiedKFold(random_state=125)

是否有一种方法可以调用
管道。get_model()

管道。get_params()
?使用
命名的步骤<代码>管道。命名为步骤['grid']。在您的案例中是最好的估算器。看,你的案子和我的问题正好相反。在这种情况下,管道位于网格搜索内,因此我们首先访问
最佳估计量
以获取管道,然后使用
命名步骤
。在您的案例中,我们首先使用
命名的\u步骤
获取内部网格搜索对象,然后使用
最佳\u估计器
从网格搜索中获取找到的最佳RF模型。无论如何,您的场景(管道内的网格搜索)有点不寻常。为什么要使用管道上方网格搜索。在将管道中的数据发送到网格搜索之前,您是否对这些数据执行任何其他操作?如果是,那么您需要确保它不会将测试信息泄漏到网格搜索模型中,否则您将得到有偏差的结果。