Skip to content

Commit

Permalink
FIX: make normalizer use the real l1 norm on each row (without assumi…
Browse files Browse the repository at this point in the history
…ng positive values)
  • Loading branch information
ogrisel committed Apr 28, 2011
1 parent 7b70505 commit c674b6c
Show file tree
Hide file tree
Showing 4 changed files with 2,556 additions and 1,510 deletions.
2 changes: 1 addition & 1 deletion scikits/learn/preprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def fit(self, X, **params):
def transform(self, X, copy=True):
if copy:
X = X.copy()
norms = X.sum(axis=1)[:, np.newaxis]
norms = np.abs(X).sum(axis=1)[:, np.newaxis]

This comment has been minimized.

Copy link
@mblondel

mblondel Apr 28, 2011

Member

Too bad there isn't a np.abssum function. The above makes a copy of the dataset. Or likewise, too bad that linalg.norm doesn't have an axis argument.

This comment has been minimized.

Copy link
@ogrisel

ogrisel Apr 28, 2011

Author Member

If we get rid off the sparse subpackage we can write a cython function with fabs from math.h for the dense case as well.

This comment has been minimized.

Copy link
@mblondel

mblondel via email Apr 28, 2011

Member
norms[norms == 0.0] = 1.0
X /= norms

Expand Down
Loading

0 comments on commit c674b6c

Please sign in to comment.