Min-Max Normalization

Beginner
~10 min
code completion

Min-Max Normalization

Min-max normalization scales features to a fixed range, typically [0, 1]:

This ensures all features have equal weight when a model computes distances or uses gradient descent.

In NumPy:

X_norm = (X - X.min()) / (X.max() - X.min())

Your task:

Implement min_max_normalize(X) that scales all values to [0, 1]. Assume X.max() != X.min().

Example Tests

Simple 3-element array

Input: {"X":[0,5,10]}

Expected: [0,0.5,1]

Negative to positive range

Input: {"X":[-10,0,10]}

Expected: [0,0.5,1]

5-element array

Input: {"X":[1,2,3,4,5]}

Expected: [0,0.25,0.5,0.75,1]

Sign in to solve this problem

You can read the full problem statement above. Create a free account to run code in the browser, submit solutions, and track your progress.