Implement min–max scaling to transform data into [0,1] range.
For each feature (column):
x′=max(x)−min(x)x−min(x)Input: X = np.array([[1,2],[3,6],[5,10]])
Output: [[0,0],[0.5,0.5],[1,1]] (per-column scaling)
Use np.min() and np.max() with the appropriate axis and keepdims=True for broadcasting.
Use np.maximum(denominator, eps) to avoid division by zero when max equals min.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Implement min–max scaling to transform data into [0,1] range.
For each feature (column):
x′=max(x)−min(x)x−min(x)Input: X = np.array([[1,2],[3,6],[5,10]])
Output: [[0,0],[0.5,0.5],[1,1]] (per-column scaling)
Use np.min() and np.max() with the appropriate axis and keepdims=True for broadcasting.
Use np.maximum(denominator, eps) to avoid division by zero when max equals min.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number