GitHub user willb opened a pull request:

    https://github.com/apache/spark/pull/15105

    [SPARK-17548] [MLlib] Word2VecModel.findSynonyms no longer spuriously 
rejects the best match when invoked with a vector

    ## What changes were proposed in this pull request?
    
    This pull request changes the behavior of `Word2VecModel.findSynonyms` so 
that it will not spuriously reject the best match when invoked with a vector 
that does not correspond to a word in the model's vocabulary.  Instead of 
blindly discarding the best match, the changed implementation discards a match 
that corresponds to the query word (in cases where `findSynonyms` is invoked 
with a word) or that has an identical angle to the query vector.
    
    ## How was this patch tested?
    
    I added a test to `Word2VecSuite` to ensure that the word with the most 
similar vector from a supplied vector would not be spuriously rejected.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/willb/spark fix/findSynonyms

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/15105.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 #15105
    
----
commit 5a7cf31e1c76c2fe4e172c2889fa23deb2152af9
Author: William Benton <wi...@redhat.com>
Date:   2016-09-14T17:07:14Z

    test for spurious rejection of similar vectors in findSynonyms

commit 757ce7c73e76f751395d55de3b5b31fa4a05cde8
Author: William Benton <wi...@redhat.com>
Date:   2016-09-14T21:35:29Z

    `Word2VecModel.findSynonyms` no longer spuriously rejects the best match
    
    Previously, the `findSynonyms` method in `Word2VecModel` rejected the
    closest-matching vector.  This was typically correct in cases where we
    were searching for synonyms of a word, but was incorrect in cases
    where we were searching for words most similar to a given vector,
    since the given vector might not correspond to a word in the model's
    vocabulary.
    
    With this commit, `findSynonyms` will not discard the best matching
    term unless the best matching word is also the query word (or is
    maximally similar to the query vector).

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to