Using explicit (predefined) validation set for grid search with sklearn

前端 未结 3 1623
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 17:38

I have a dataset, which has previously been split into 3 sets: train, validation and test. These sets have to be used as given in order to compare the performance across dif

3条回答
  •  [愿得一人]
    2020-12-07 18:17

    Use PredefinedSplit

    ps = PredefinedSplit(test_fold=your_test_fold)
    

    then set cv=ps in GridSearchCV

    test_fold : “array-like, shape (n_samples,)

    test_fold[i] gives the test set fold of sample i. A value of -1 indicates that the corresponding sample is not part of any test set folds, but will instead always be put into the training fold.

    Also see here

    when using a validation set, set the test_fold to 0 for all samples that are part of the validation set, and to -1 for all other samples.

提交回复
热议问题