def normalize(data):
    """Min-Max normalization: rescale to [0,1]"""
    data_min = data.min(axis=1).reshape((-1, 1))
    data_max = data.max(axis=1).reshape((-1, 1))
    data_range = (data_max - data_min) + (data_max == data_min)
    return (data - data_min) / data_range