Problem 4: Split Then Scale Correctly
Easypython
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
textfeature = [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.