Problem 3: Scale Features Before Applying KNN
Easypython
Problem Description
Write a Python program that scales two features with very different ranges using StandardScaler, then trains a KNN classifier on the scaled data.
Input
A dataset with two features of very different scales, and labels.
Output
The trained model's prediction for a new, appropriately scaled data point.
Constraints
- None specific.
Example Input
textX=[[1,50000],[2,55000],[9,150000],[10,160000]], y=[0,0,1,1], new=[[5,100000]]
Example Output
textPrediction: [1] (or [0], depending on exact scaling — the key requirement is that scaling was applied consistently)
Concepts Covered
StandardScaler, KNeighborsClassifier, consistent scaling of new data.