GitHub user maximerihouey opened a pull request:
https://github.com/apache/spark/pull/15503
Fix example of tf_idf with minDocFreq
## What changes were proposed in this pull request?
The python example for tf_idf with the parameter "minDocFreq" is not
properly set up because the same variable is used to transform the document for
both with and without the "minDocFreq" parameter.
The IDF(minDocFreq=2) is stored in the variable "idfIgnore" but then it is
the original variable "idf" used to transform the "tf" instead of the
"idfIgnore".
## How was this patch tested?
Before the results for "tfidf" and "tfidfIgnore" were the same:
tfidf:
(1048576,[1046921],[3.75828890549])
(1048576,[1046920],[3.75828890549])
(1048576,[1046923],[3.75828890549])
(1048576,[892732],[3.75828890549])
(1048576,[892733],[3.75828890549])
(1048576,[892734],[3.75828890549])
tfidfIgnore:
(1048576,[1046921],[3.75828890549])
(1048576,[1046920],[3.75828890549])
(1048576,[1046923],[3.75828890549])
(1048576,[892732],[3.75828890549])
(1048576,[892733],[3.75828890549])
(1048576,[892734],[3.75828890549])
After the fix those are how they should be:
tfidf:
(1048576,[1046921],[3.75828890549])
(1048576,[1046920],[3.75828890549])
(1048576,[1046923],[3.75828890549])
(1048576,[892732],[3.75828890549])
(1048576,[892733],[3.75828890549])
(1048576,[892734],[3.75828890549])
tfidfIgnore:
(1048576,[1046921],[0.0])
(1048576,[1046920],[0.0])
(1048576,[1046923],[0.0])
(1048576,[892732],[0.0])
(1048576,[892733],[0.0])
(1048576,[892734],[0.0])
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/maximerihouey/spark patch-1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/15503.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #15503
----
commit d8f3ce53851b04303cf0639fb8de3261b0b56dad
Author: Maxime Rihouey <[email protected]>
Date: 2016-10-15T22:13:41Z
Fix example of tf_idf with minDocFreq
The IDF(minDocFreq=2) is stored in the variable "idfIgnore" but then it is
the original variable "idf" used to transform the "tf" instead of the
"idfIgnore".
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]