hypertools.tools.gensim_models.Word2VecVectorizer

class hypertools.tools.gensim_models.Word2VecVectorizer(vector_size=100, window=5, min_count=1, epochs=10, seed=0, workers=None)[source]

Vectorizer-stage model: a document’s vector is the mean of its tokens’ trained gensim Word2Vec word vectors (out-of-vocabulary tokens at transform time are skipped; a document with no known tokens gets the zero vector).

Parameters:
vector_sizeint

Dimensionality of the word (and, by averaging, document) vectors. Default: 100.

windowint

Maximum distance between the current and predicted word within a sentence. Default: 5.

min_countint

Ignores all words with total frequency lower than this. Default: 1 (so short synthetic corpora keep every word).

epochsint

Number of training epochs. Default: 10.

seedint or None

Random seed for reproducible training. Default: 0. When not None, training is forced single-threaded (see _effective_workers) – multi-threaded gensim training is not reproducible even with a fixed seed.

workersint or None

Number of worker threads. Default: None, which resolves to 1 when seed is not None (deterministic) or 4 otherwise.

Attributes:
model_gensim.models.Word2Vec

The trained Word2Vec model (set by fit).

Methods

fit(X[, y])

Train a Word2Vec model on the given documents.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Embed documents as the mean of their trained word vectors.

__init__(vector_size=100, window=5, min_count=1, epochs=10, seed=0, workers=None)[source]

Methods

__init__([vector_size, window, min_count, ...])

fit(X[, y])

Train a Word2Vec model on the given documents.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Embed documents as the mean of their trained word vectors.