Implement Min-Max Normalization
Implement Min-Max Normalization
Implement min–max scaling to transform data into [0,1] range.
For each feature (column):
x′=max(x)−min(x)x−min(x)Examples
Input: X = np.array([[1,2],[3,6],[5,10]])
Output: [[0,0],[0.5,0.5],[1,1]] (per-column scaling)
Hint 1
Use np.min() and np.max() with the appropriate axis and keepdims=True for broadcasting.
Hint 2
Use np.maximum(denominator, eps) to avoid division by zero when max equals min.
Requirements
- Accept 1D or 2D NumPy arrays
- Vectorized; no Python loops
- Avoid divide-by-zero when max==min (use eps)
- Return np.ndarray (float)
Constraints
- Up to 10⁶ elements
- NumPy only
Log in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Implement Min-Max Normalization
Implement Min-Max Normalization
Implement min–max scaling to transform data into [0,1] range.
For each feature (column):
x′=max(x)−min(x)x−min(x)Examples
Input: X = np.array([[1,2],[3,6],[5,10]])
Output: [[0,0],[0.5,0.5],[1,1]] (per-column scaling)
Hint 1
Use np.min() and np.max() with the appropriate axis and keepdims=True for broadcasting.
Hint 2
Use np.maximum(denominator, eps) to avoid division by zero when max equals min.
Requirements
- Accept 1D or 2D NumPy arrays
- Vectorized; no Python loops
- Avoid divide-by-zero when max==min (use eps)
- Return np.ndarray (float)
Constraints
- Up to 10⁶ elements
- NumPy only
Log in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number