I've read this question which seems similar but answers didn't address when we would want to normalize by sample (row): Should I normalize featurewise or samplewise
I ask specifically about normalization by the L1 norm for simplicity but also applies to L2 normalization.
In both scikit-learn and pyspark the default is to normalize across sample (row) rather than across feature. This surprised me since I find it hard to think of an occasion where we would want to normalize our features over the rows of the data rather than the feature column. Can anyone give an example of where this would be useful?
In case the row-wise and column-wise distinction is not clear:
x y x_row_norm x_column_norm
1 1 10 0.0909 0.167
2 2 20 0.0909 0.333
3 3 30 0.0909 0.5
where the l1 norm is sum(|x|)
, normalizing across the row is given by 1/(1+10) = 0.0909 while normalizing by feature (column) is 1/(1+2+3) = 1.167