Skip to content
CampusEduX

Problem 4: Split Then Scale Correctly

Easypython
Learn the Concept: Train-Test Split

Problem Description

Write a Python program that first splits a dataset into training and test sets, then fits a StandardScaler on the training set only, and applies it to both sets — demonstrating the correct order of operations.

Input

A dataset with one numeric feature column.

Output

The scaled training and test sets, confirming the scaler was fit only on the training data.

Constraints

  • None specific.

Example Input

text
feature = [10, 20, 30, 40, 50, 60, 70, 80]

Example Output

text
(Scaled training and test data, using scaling parameters derived only from the training set)

Concepts Covered

train_test_split(), StandardScaler, correct preprocessing order.

Related Problems

  • Problem 1: Basic Train-Test Split
    Easy · python
    Solve Problem
  • Problem 2: Reproducible Split with random_state
    Easy · python
    Solve Problem
  • Problem 3: Stratified Split for Imbalanced Classes
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...