Skip to content

[FAQ]Why should we use the same KFold splits when comparing hyperparameters? #480

Open

Description

@AMIRABBASBF2027

Course

machine-learning-zoomcamp

Question

Why should we use the same KFold splits when comparing different hyperparameter values?

Answer

When comparing different hyperparameter values, such as different values of C in Logistic Regression, we want the comparison to reflect the effect of the hyperparameter rather than differences in the data splits.

Using the same KFold configuration:

KFold(n_splits=5, shuffle=True, random_state=1)

makes the comparison reproducible and allows each value of C to be evaluated using the same fold assignments.

If different random splits are used for every value of C, differences in the mean AUC may partly come from the different train/validation splits rather than from C itself.

Using the same folds therefore makes the comparison between hyperparameter values fairer and easier to reproduce.

Checklist

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Activity

  1. github-actions commented on Oct 19, 2026

    @github-actions
    Contributor

    ✅ FAQ NEW proposal created in PR #481

    Please review and approve the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions