Implement z-Score Standardization
Implement z-Score Standardization
Standardize features to zero mean and unit variance.
z=σx−μwith μ mean and σ standard deviation.
Examples
Input: X = np.array([[1,2],[3,6],[5,10]])
Output: Standardized columns (mean≈0, std≈1)
Hint 1
Use np.mean() and np.std() with the appropriate axis and keepdims=True.
Hint 2
Use std + eps in the denominator to avoid division by zero when standard deviation is 0.
Requirements
- Handle 1D and 2D arrays
- Vectorized; avoid divide-by-zero (use eps)
- Return np.ndarray (float)
Constraints
- Up to 10⁶ elements
- NumPy only
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Implement z-Score Standardization
Implement z-Score Standardization
Standardize features to zero mean and unit variance.
z=σx−μwith μ mean and σ standard deviation.
Examples
Input: X = np.array([[1,2],[3,6],[5,10]])
Output: Standardized columns (mean≈0, std≈1)
Hint 1
Use np.mean() and np.std() with the appropriate axis and keepdims=True.
Hint 2
Use std + eps in the denominator to avoid division by zero when standard deviation is 0.
Requirements
- Handle 1D and 2D arrays
- Vectorized; avoid divide-by-zero (use eps)
- Return np.ndarray (float)
Constraints
- Up to 10⁶ elements
- NumPy only
Try Similar Problems
Log in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number