Standardise using training statistics
Question
Write Python functions that fit feature means and population standard deviations on training data and apply them to another matrix. Define a policy for constant columns.
Short answer
Use training statistics unchanged for the other matrix. Replace a zero standard deviation by one so a constant training column becomes zero without division by zero. A new value in that column remains interpretable relative to the training constant.
Original question and answer written by SelfMadeQuant.com.
See the hint and the full worked solution in the question bank (free account).
Open the worked solutionLessons behind this question
- The Supervised Learning Problem and the ML Pipeline
- Covariance and Correlation
- Populations, Samples, and Sampling Distributions
Start with a free lesson: Expectation, Variance and Covariance is part of a free topic. Create a free account, no card needed, to read it in full with worked solutions.
Read it free