【问题标题】:gridsearchCV - shuffle data for every single parameter combinationgridsearchCV - 每个参数组合的随机数据
【发布时间】:2021-10-18 12:22:03
【问题描述】:

我正在使用 gridsearchCV 来确定模型超参数:

pipe = Pipeline(steps=[(self.FE, FE_algorithm), (self.CA, Class_algorithm)])
param_grid = {**FE_grid, **CA_grid} 

scorer = make_scorer(f1_score, average='macro')
       
search = GridSearchCV(pipe, param_grid, cv=ShuffleSplit(test_size=0.20, n_splits=5,random_state=0), n_jobs=-1,
                              verbose=3, scoring=scorer)

search.fit(self.data_input, self.data_output)

但是,我相信我遇到了一些过度拟合的问题: results

我想对每个参数组合下的数据进行洗牌,有什么办法吗?目前,通过 k 折交叉验证,正在为每个参数组合评估相同的验证数据集k-fold,因此过度拟合正在成为一个问题。

【问题讨论】:

    标签: scikit-learn shuffle gridsearchcv overfitting-underfitting


    【解决方案1】:

    不,没有。搜索将数据拆分一次,并为折叠和参数组合的每个组合创建一个任务 (source)。

    每个参数组合的混洗可能无论如何都是不可取的:然后选择可能只是选择“最简单”的拆分而不是“最佳”参数。如果您认为您对验证折叠过度拟合,请考虑使用

    1. 更少的参数选项
    2. 更多折叠或重复拆分*
    3. 自定义评估的 scoring 可调用对象
    4. 更保守的模型

    *我最喜欢的,虽然计算成本可能太高了

    【讨论】:

      猜你喜欢
      • 2014-08-29
      • 2021-08-07
      • 2018-01-03
      • 2020-10-12
      • 1970-01-01
      • 2016-05-11
      • 2017-09-21
      • 2017-03-30
      • 1970-01-01
      相关资源
      最近更新 更多