Closed
Description
Describe the bug
L inf normalizer should take the maximum of the absolute value before dividing the array.
Steps/Code to Reproduce
from sklearn.preprocessing import Normalizer
import numpy as np
a = np.array([[1]])
normalizer = Normalizer(norm='max')
b = normalizer.fit_transform(a)
c = normalizer.fit_transform(-a)
# they should be different
print(b, c)
Expected Results
The normalized version of a vector with only negative elements should remain negative. It should take maximum absolute value, which is positive, hence remains negative.
Actual Results
The normalization applied to a positive-only vector and to a negative-only vector returns the same results.
Versions
Python dependencies:
pip: 19.0.3
setuptools: 40.8.0
sklearn: 0.22.2.post1
numpy: 1.18.1
scipy: 1.4.1
Cython: None
pandas: None
matplotlib: 3.1.3
joblib: 0.14.1
Possible fix
Take the absolute value before taking the max in this line.
Thanks to @freezebat for identifying the problem