Word2VecModel

class pyspark.mllib.feature.Word2VecModel(java_model)[source]

class for Word2Vec model

New in version 1.2.0.

Methods

Methods Documentation

call(name, *a)

Call method of java_model

findSynonyms(word, num)[source]

Find synonyms of a word

Parameters
  • word – a word or a vector representation of word

  • num – number of synonyms to find

Returns

array of (word, cosineSimilarity)

Note

Local use only

New in version 1.2.0.

getVectors()[source]

Returns a map of words to their vector representations.

New in version 1.4.0.

classmethod load(sc, path)[source]

Load a model from the given path.

New in version 1.5.0.

save(sc, path)

Save this model to the given path.

New in version 1.3.0.

transform(word)[source]

Transforms a word to its vector representation

Note

Local use only

Parameters

word – a word

Returns

vector representation of word(s)

New in version 1.2.0.