Min-Max Scaling of Feature Values

Easy
Data Science Interview Prep

Implement a function that performs Min-Max Normalization on a list of integers, scaling all values according to the formula. Min-Max normalization helps ensure that all features contribute equally to a model by scaling them to a common range.

Examples

Example 1:
Input: min_max([1, 2, 3, 4, 5])
Output: [0.0, 0.25, 0.5, 0.75, 1.0]
Explanation: The minimum value (1) becomes 0.0, the maximum value (5) becomes 1.0, and the values in between are scaled proportionally. For instance, 3 is exactly halfway between 1 and 5, so it becomes 0.5.

Starter Code

def min_max(x: list[float]) -> list[float]:
    """
    Perform Min-Max normalization to scale values to [0, 1].
    
    Args:
        x: A list of numerical values
    
    Returns:
        A new list with values normalized to [0, 1]
    """
    # Your code here
    pass
Lines: 1Characters: 0
Ready
The AI Interview - Master AI/ML Interviews