No Peeking
Test rows must stay unseen, even by the scaler: if their mean and spread leak into the scaling, the test is no longer honest. Standardize X_test using the mean and standard deviation of each column of X_train only, and return the result.
Example 1
X_train [[0],[10]]
X_test [[5],[20]]
returns [[0.0],[3.0]]
The training column has mean 5 and standard deviation 5, so 5 becomes 0 and 20 becomes 3.
Constraints
- 2 to 30 training rows, 1 to 8 test rows, 1 to 3 columns
- No training column is constant
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- Scale Then VoteMedium
- Shrunken SlopesMedium
- Two Main DirectionsMedium
- Words to CountsMedium
- How Many GroupsHard
- Keep the Useful ColumnsHard
- Leak-Free ScoreHard
- Mixed ColumnsHard