Skip to content
CampusEduX

Problem 2: Compare Different Values of k

Easypython
Learn the Concept: Cross-Validation

Problem Description

Write a Python program that performs Cross-Validation with k=3, k=5, and k=10 on the same model and dataset, comparing the resulting mean scores.

Input

A labeled dataset.

Output

The mean score for each value of k.

Constraints

  • At least 15 labeled examples (to reasonably support k=10).

Example Input

text
(A labeled dataset with 15+ examples)

Example Output

text
k=3: Mean accuracy = 0.87 k=5: Mean accuracy = 0.90 k=10: Mean accuracy = 0.91

Concepts Covered

cross_val_score(), comparing cv values.

Related Problems

  • Problem 1: Perform Basic 5-Fold Cross-Validation
    Easy · python
    Solve Problem
  • Problem 3: Use Stratified K-Fold on Imbalanced Data
    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...