12
$\begingroup$

I was wondering if anyone here can explain the difference between the $L1$, $L2$ and $Max$ normalization mode in sklearn.preprocessing.normalize() module?

Having read the documentation, I couldn't realize the difference!

$\endgroup$

1 Answer 1

21
$\begingroup$

The options lead to different normalizations. if $x$ is the vector of covariates of length $n$, and say that the normalized vector is $y = x / z$ then the three options denote what to use for $z$:

  • L1: $z = \| x\|_1 = \sum_{i=1}^n |x_i|$
  • L2: $z = \| x\|_2 = \sqrt{\sum_{i=1}^n x_i^2}$
  • Max: $z = \max x_i$

Note that using Max does not take absolute values first, so it is not equal to the $l_\infty$ norm.

(source code)

$\endgroup$
1
  • $\begingroup$ If Max does not take absolute values first, would you get strange results when all the $x_i$ are negative, or worse if one or more were 0 and the rest negative? $\endgroup$
    – Henry
    Feb 16 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.