Skip to content
CampusEduX

Problem 1: Basic Train-Test Split

Easypython
Learn the Concept: Train-Test Split

Problem Description

Write a Python program that splits a dataset into training (80%) and testing (20%) sets using train_test_split(), and prints the resulting shapes.

Input

A dataset with features (X) and a label (y).

Output

The shapes of Xtrain, Xtest, ytrain, and ytest.

Constraints

  • The dataset will contain at least 10 rows.

Example Input

text
X with 100 rows, y with 100 rows, test_size=0.2

Example Output

text
X_train shape: (80, n_features) X_test shape: (20, n_features)

Concepts Covered

train_test_split(), test_size.

Related Problems

  • Problem 2: Reproducible Split with random_state
    Easy · python
    Solve Problem
  • Problem 3: Stratified Split for Imbalanced Classes
    Easy · python
    Solve Problem
  • Problem 4: Split Then Scale Correctly
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...