TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Min-Max Scaling

Feature EngineeringData Processing
Medium

Min-max scaling transforms every feature column independently into the range from 0 through 1. For a value in row i and column j, compute

xij′=xij−min⁡jmax⁡j−min⁡jx'_{ij} = \frac{x_{ij} - \min_j}{\max_j - \min_j}xij′​=maxj​−minj​xij​−minj​​

The numerator subtracts the minimum value of column j, and the denominator is that column's maximum minus its minimum. If a column is constant, the denominator is zero; map every value in that column to 0.0. Return a floating-point matrix with the same shape as data.

Loading visualization...

Examples

Input: data = [[1, 10], [2, 20], [3, 30]]

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: data = [[0, 0], [10, 100], [20, 50]]

Output: [[0.0, 0.0], [0.5, 1.0], [1.0, 0.5]]

Hint 1

Collect the minimum and maximum of one column before scaling its entries.

Hint 2

Initialize an output matrix with the same row and column counts as data.

Requirements

  • Scale every column independently.
  • Map each column minimum to 0.0 and maximum to 1.0.
  • Map a constant column entirely to 0.0.
  • Return a list of floating-point rows with the input shape.

Constraints

  • data is a nonempty rectangular matrix.
  • Every matrix entry is numeric.
  • Time limit: 300 ms.
Try Similar Problems
Minmax NormalizationStreaming MinmaxZscore StandardizationRobust ScalingLog Transform

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

You must run your code first.
PrevNext

Min-Max Scaling

Feature EngineeringData Processing
Medium

Min-max scaling transforms every feature column independently into the range from 0 through 1. For a value in row i and column j, compute

xij′=xij−min⁡jmax⁡j−min⁡jx'_{ij} = \frac{x_{ij} - \min_j}{\max_j - \min_j}xij′​=maxj​−minj​xij​−minj​​

The numerator subtracts the minimum value of column j, and the denominator is that column's maximum minus its minimum. If a column is constant, the denominator is zero; map every value in that column to 0.0. Return a floating-point matrix with the same shape as data.

Loading visualization...

Examples

Input: data = [[1, 10], [2, 20], [3, 30]]

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: data = [[0, 0], [10, 100], [20, 50]]

Output: [[0.0, 0.0], [0.5, 1.0], [1.0, 0.5]]

Hint 1

Collect the minimum and maximum of one column before scaling its entries.

Hint 2

Initialize an output matrix with the same row and column counts as data.

Requirements

  • Scale every column independently.
  • Map each column minimum to 0.0 and maximum to 1.0.
  • Map a constant column entirely to 0.0.
  • Return a list of floating-point rows with the input shape.

Constraints

  • data is a nonempty rectangular matrix.
  • Every matrix entry is numeric.
  • Time limit: 300 ms.
Try Similar Problems
Minmax NormalizationStreaming MinmaxZscore StandardizationRobust ScalingLog Transform

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

You must run your code first.