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

Implement Min-Max Normalization

Feature EngineeringData Processing
Easy

Scale numeric data to the interval [0,1][0,1][0,1]. For each slice selected by axis, compute

x′=x−xmin⁡xmax⁡−xmin⁡x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}x′=xmax​−xmin​x−xmin​​

Here, xmin⁡x_{\min}xmin​ and xmax⁡x_{\max}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.

Loading visualization...

Examples

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]]

Hint 1

Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.

Hint 2

Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.

Requirements

  • Compute minima and maxima along the selected axis
  • Preserve dimensions during reductions so values broadcast back to X
  • Map every slice with range at most eps to zeros
  • Return a NumPy array of floating-point values

Constraints

  • X is a nonempty one-dimensional or two-dimensional numeric list
  • axis is 0 for one-dimensional inputs and either 0 or 1 for two-dimensional inputs
  • eps is positive
  • Use NumPy only
Try Similar Problems
One Hot EncodingStreaming MinmaxMin Max ScalingZscore StandardizationRobust Scaling

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

You must run your code first.
PrevNext

Implement Min-Max Normalization

Feature EngineeringData Processing
Easy

Scale numeric data to the interval [0,1][0,1][0,1]. For each slice selected by axis, compute

x′=x−xmin⁡xmax⁡−xmin⁡x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}x′=xmax​−xmin​x−xmin​​

Here, xmin⁡x_{\min}xmin​ and xmax⁡x_{\max}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.

Loading visualization...

Examples

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]]

Hint 1

Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.

Hint 2

Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.

Requirements

  • Compute minima and maxima along the selected axis
  • Preserve dimensions during reductions so values broadcast back to X
  • Map every slice with range at most eps to zeros
  • Return a NumPy array of floating-point values

Constraints

  • X is a nonempty one-dimensional or two-dimensional numeric list
  • axis is 0 for one-dimensional inputs and either 0 or 1 for two-dimensional inputs
  • eps is positive
  • Use NumPy only
Try Similar Problems
One Hot EncodingStreaming MinmaxMin Max ScalingZscore StandardizationRobust Scaling

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

You must run your code first.