Skip to content

Commit

Permalink
Fix sklearn_api bug with documents_columns parameter. Fix piskvorky#1676
Browse files Browse the repository at this point in the history
 (piskvorky#1704)

* updated param passed to 'Sparse2Corpus'

* updated unit test

* updated 'partial_fit' and passed named params
  • Loading branch information
chinmayapancholi13 authored and KMarie1 committed Nov 26, 2017
1 parent fb05df2 commit 76983da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gensim/sklearn_api/hdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fit(self, X, y=None):
Calls gensim.models.HdpModel
"""
if sparse.issparse(X):
corpus = matutils.Sparse2Corpus(X)
corpus = matutils.Sparse2Corpus(sparse=X, documents_columns=False)
else:
corpus = X

Expand Down Expand Up @@ -95,7 +95,7 @@ def partial_fit(self, X):
Train model over X.
"""
if sparse.issparse(X):
X = matutils.Sparse2Corpus(X)
X = matutils.Sparse2Corpus(sparse=X, documents_columns=False)

if self.gensim_model is None:
self.gensim_model = models.HdpModel(
Expand Down
4 changes: 2 additions & 2 deletions gensim/sklearn_api/ldamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def fit(self, X, y=None):
Calls gensim.models.LdaModel
"""
if sparse.issparse(X):
corpus = matutils.Sparse2Corpus(X)
corpus = matutils.Sparse2Corpus(sparse=X, documents_columns=False)
else:
corpus = X

Expand Down Expand Up @@ -102,7 +102,7 @@ def partial_fit(self, X):
"""
if sparse.issparse(X):
X = matutils.Sparse2Corpus(X)
X = matutils.Sparse2Corpus(sparse=X, documents_columns=False)

if self.gensim_model is None:
self.gensim_model = models.LdaModel(
Expand Down
4 changes: 2 additions & 2 deletions gensim/sklearn_api/lsimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def fit(self, X, y=None):
Calls gensim.models.LsiModel
"""
if sparse.issparse(X):
corpus = matutils.Sparse2Corpus(X)
corpus = matutils.Sparse2Corpus(sparse=X, documents_columns=False)
else:
corpus = X

Expand Down Expand Up @@ -78,7 +78,7 @@ def partial_fit(self, X):
Train model over X.
"""
if sparse.issparse(X):
X = matutils.Sparse2Corpus(X)
X = matutils.Sparse2Corpus(sparse=X, documents_columns=False)

if self.gensim_model is None:
self.gensim_model = models.LsiModel(
Expand Down
2 changes: 1 addition & 1 deletion gensim/test/test_sklearn_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def testCSRMatrixConversion(self):
newmodel.fit(sarr)
bow = [(0, 1), (1, 2), (2, 0)]
transformed_vec = newmodel.transform(bow)
expected_vec = numpy.array([0.35367903, 0.64632097])
expected_vec = numpy.array([0.12843782, 0.87156218])
passed = numpy.allclose(transformed_vec, expected_vec, atol=1e-1)
self.assertTrue(passed)

Expand Down

0 comments on commit 76983da

Please sign in to comment.