When is stratified k-fold cross-validation preferred over standard k-fold cross-validation?

Quick Overview

A cross-validation question asking when stratified k-fold should be used instead of plain k-fold for evaluating a classifier. It tests reasoning about class balance across folds, the spread of per-fold metrics, library defaults, and choosing a splitting scheme that fits the data.

When is stratified k-fold cross-validation preferred over standard k-fold cross-validation?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

When is stratified k-fold cross-validation preferred over standard k-fold cross-validation? ```hint Look at one fold Consider how many examples of each class land in a test fold when folds are drawn without looking at the label, and what a metric such as recall or AUC needs in order to be computed. ``` ### What a Strong Answer Covers - What stratification guarantees about the class mix of each fold - The situations where plain k-fold folds can differ a lot in class mix, and what that does to per-fold metrics - The effect on the spread of fold scores - What scikit-learn does by default for classifiers - Cases where stratified k-fold is not enough or does not apply ### Follow-up Questions - How would you stratify a regression problem, and how would you choose the bins? - What do you do when the rarest class has fewer examples than the number of folds? - The data has several rows per user and a rare positive class. How do you split it? - Production traffic has a different class balance from the training data. Does stratified cross-validation tell you how the model will perform there?

Overview: A cross-validation question asking when stratified k-fold should be used instead of plain k-fold for evaluating a classifier. It tests reasoning about class balance across folds, the spread of per-fold metrics, library defaults, and choosing a splitting scheme that fits the data.

General logo
General
Nov 24, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

When is stratified k-fold cross-validation preferred over standard k-fold cross-validation?

What a Strong Answer Covers Guidance

  • What stratification guarantees about the class mix of each fold
  • The situations where plain k-fold folds can differ a lot in class mix, and what that does to per-fold metrics
  • The effect on the spread of fold scores
  • What scikit-learn does by default for classifiers
  • Cases where stratified k-fold is not enough or does not apply

Follow-up Questions Guidance

  • How would you stratify a regression problem, and how would you choose the bins?
  • What do you do when the rarest class has fewer examples than the number of folds?
  • The data has several rows per user and a rare positive class. How do you split it?
  • Production traffic has a different class balance from the training data. Does stratified cross-validation tell you how the model will perform there?