-
-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: make normalizer use the real l1 norm on each row (without assumi…
…ng positive values)
- Loading branch information
Showing
4 changed files
with
2,556 additions
and
1,510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ogrisel
Author
Member
|
||
norms[norms == 0.0] = 1.0 | ||
X /= norms | ||
|
||
|
Oops, something went wrong.
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.