Scale numeric data to the interval [0,1]. For each slice selected by axis, compute
x′=xmax−xminx−xminHere, xmin and xmax are the minimum and maximum of the same slice. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has range at most eps, return zeros for that slice. Return the scaled values as a NumPy array.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-12
Output: [[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]
Explanation: Each column is scaled using its own minimum and maximum.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 1, eps = 1e-12
Output: [[0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]
Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.
Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Scale numeric data to the interval [0,1]. For each slice selected by axis, compute
x′=xmax−xminx−xminHere, xmin and xmax are the minimum and maximum of the same slice. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has range at most eps, return zeros for that slice. Return the scaled values as a NumPy array.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-12
Output: [[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]
Explanation: Each column is scaled using its own minimum and maximum.
Input: X = [[1, 2], [3, 6], [5, 10]], axis = 1, eps = 1e-12
Output: [[0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]
Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.
Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number