TensorTonicTensorTonic
Problems
Study PlansProjectsInterviewPricingFeedback
Problems
Loading...
1 / 1

Implement Min-Max Normalization

Feature EngineeringData Processing
Easy

Implement min–max scaling to transform data into [0,1] range.

For each feature (column):

x′=x−min⁡(x)max⁡(x)−min⁡(x)x' = \frac{x - \min(x)}{\max(x) - \min(x)}x′=max(x)−min(x)x−min(x)​
Loading visualization...

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

Implement min–max scaling to transform data into [0,1] range.

For each feature (column):

x′=x−min⁡(x)max⁡(x)−min⁡(x)x' = \frac{x - \min(x)}{\max(x) - \min(x)}x′=max(x)−min(x)x−min(x)​
Loading visualization...

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