Skip to content
CampusEduX

Problem 3: Use Stratified K-Fold on Imbalanced Data

Easypython
Learn the Concept: Cross-Validation

Problem Description

Write a Python program that applies Stratified K-Fold Cross-Validation to an imbalanced classification dataset, and prints the resulting fold scores.

Input

An imbalanced labeled dataset.

Output

The fold scores using Stratified K-Fold.

Constraints

  • At least 20 labeled examples, with a clear class imbalance.

Example Input

text
(An imbalanced dataset with 20 examples, 16 of class 0 and 4 of class 1)

Example Output

text
Stratified fold scores: [0.8, 0.75, 0.85, 0.8, 0.9]

Concepts Covered

StratifiedKFold, cross_val_score().

Related Problems

  • Problem 1: Perform Basic 5-Fold Cross-Validation
    Easy · python
    Solve Problem
  • Problem 2: Compare Different Values of k
    Easy · python
    Solve Problem
  • Problem 4: Compare Cross-Validation Mean and Standard Deviation for Two Models
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...