Skip to content

Commit

Permalink
Changed lil_matrix to dia_matrix speeds up a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
cdegroc committed Mar 21, 2012
1 parent a734166 commit c57bfdd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions sklearn/feature_extraction/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ def transform(self, X, copy=True):
raise ValueError("Input has n_features=%d while the model"
" has been trained with n_features=%d" % (
n_features, expected_n_features))
d = sp.lil_matrix((n_features, n_features))
d.setdiag(self.idf_)
d = sp.dia_matrix((self.idf_, 0), shape=(n_features, n_features))
# *= doesn't work
X = X * d

Expand Down

0 comments on commit c57bfdd

Please sign in to comment.