Skip to content
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

Update 'documents_columns' param passed to 'Sparse2Corpus' #1704

Merged
merged 3 commits into from
Nov 20, 2017

Conversation

chinmayapancholi13
Copy link
Contributor

Fixes issue #1676.
cc: @mmunozm @menshikh-iv

@menshikh-iv
Copy link
Contributor

I'm glad to see you @chinmayapancholi13, have you returned to us 😃 ?

Copy link
Contributor

@menshikh-iv menshikh-iv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please, add tests based on issue

@@ -57,7 +57,7 @@ def fit(self, X, y=None):
Calls gensim.models.LdaModel
"""
if sparse.issparse(X):
corpus = matutils.Sparse2Corpus(X)
corpus = matutils.Sparse2Corpus(X, False)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named parameter better, for clarity. (here and elsewhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Done now.

@@ -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])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because now this script interprets the input differently -> different model -> different result, but looks suspicious, I agree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piskvorky As Ivan correctly pointed out, since the input matrix used for training (by fit method) is being interpreted differently after making this change, the model changes and thus, the output of transform changes as well.

@chinmayapancholi13
Copy link
Contributor Author

@menshikh-iv Right now, among the unit-tests, we have a function testCSRMatrixConversion() only for LDA model (and not for HDP and LSI models). So should I add tests with CSR matrices for these models as well?

And should we add separate unit-tests to ensure that input matrix is being inpterpreted in the right manner or just having a function like the current version of testCSRMatrixConversion() would be fine? I mean that currently testCSRMatrixConversion() function compares the output of transform() on the trained model (with a fixed expected output vector) after calling fit(). So we are inherently verifying that the input matrix is being interpreted in the right manner.

Also, I'm sorry for the delayed response. I am still a little busy in some university projects so it might take a few more weeks to resume the work here. 😄

@menshikh-iv
Copy link
Contributor

I dont think that additional tests is needed here (all changes exactly similar), LGTM for me, @piskvorky wdyt?

@piskvorky
Copy link
Owner

Up to you. Just checking: no default gensim behaviour was changed here, right? Only the wrapper.

@menshikh-iv
Copy link
Contributor

@piskvorky you are correct (only wrapper).
@chinmayapancholi13 thanks for fix 👍

@menshikh-iv menshikh-iv merged commit fff6529 into piskvorky:develop Nov 20, 2017
VaiyeBe pushed a commit to VaiyeBe/gensim that referenced this pull request Nov 26, 2017
 (piskvorky#1704)

* updated param passed to 'Sparse2Corpus'

* updated unit test

* updated 'partial_fit' and passed named params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants