【问题标题】:GridSearchCV without Cross Validation CV = 1没有交叉验证的 GridSearchCV CV = 1
【发布时间】:2020-10-17 01:58:27
【问题描述】:

我有一个特殊的数据集,这个数据集可能是有 %1 错误的火车。我需要在没有拆分训练集的情况下对 MLPRegressor 进行超参数调整。平均 cv = 1。GridSearchCV 有可能吗?

【问题讨论】:

    标签: deep-learning hyperparameters gridsearchcv


    【解决方案1】:

    cv 参数的选项之一是:

    一个可迭代的收益(训练,测试)拆分为索引数组。

    因此,如果您有 X 输入矩阵、y 目标向量、mlp 分类器和 params 网格,您可以只进行一次训练测试拆分。

    import numpy as np
    from sklearn.model_selection import train_test_split, GridSearchCV
    
    indices = np.arange(len(X))
    train_idx, test_idx = train_test_split(indices, test_size=0.2)
    clf = GridSearchCV(mlp, params, cv=[(train_idx, test_idx)])
    

    但请记住,使用 1 split 进行超参数扫描是一种不好的做法。不要用这样的网格搜索做很多步骤。

    【讨论】:

      猜你喜欢
      • 2019-04-28
      • 2018-08-27
      • 2018-08-16
      • 2015-06-12
      • 2017-06-20
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      • 2019-09-07
      相关资源
      最近更新 更多