8000 [MRG] Fix OverflowError on DictVectorizer by norvan · Pull Request #15463 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] Fix OverflowError on DictVectorizer #15463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/whats_new/v0.22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ Changelog
removes accents from strings that are in NFKD normalized form. :pr:`15100` by
:user:`Daniel Grady <DGrady>`.

- |Fix| Fixed a bug that caused :class:`feature_extraction.DictVectorizer` to raise
an `OverflowError` during the `transform` operation when producing a `scipy.sparse`
matrix on large input data. :pr:`15463` by :user:`Norvan Sahiner <norvan>`.

:mod:`sklearn.feature_selection`
................................

Expand Down
3 changes: 1 addition & 2 deletions sklearn/feature_extraction/_dict_vectorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _transform(self, X, fitting):
X = [X] if isinstance(X, Mapping) else X

indices = array("i")
indptr = array("i", [0])
indptr = [0]
# XXX we could change values to an array.array as well, but it
# would require (heuristic) conversion of dtype to typecode...
values = []
Expand Down Expand Up @@ -182,7 +182,6 @@ def _transform(self, X, fitting):
raise ValueError("Sample sequence X is empty.")

indices = np.frombuffer(indices, dtype=np.intc)
indptr = np.frombuffer(indptr, dtype=np.intc)
shape = (len(indptr) - 1, len(vocab))

result_matrix = sp.csr_matrix((values, indices, indptr),
Expand Down
0