hypertools.tools.gensim_models.HdpVectorizer

class hypertools.tools.gensim_models.HdpVectorizer(max_topics=20, seed=0)[source]

Semantic-stage model: gensim’s HdpModel (Hierarchical Dirichlet Process), which discovers its own number of topics from the data rather than taking a fixed num_topics (unlike LdaVectorizer/ LsiVectorizer). Because the discovered topic count varies by corpus, transform produces a fixed-width dense matrix by truncating to the first max_topics HDP topic indices (dropping – not renormalizing – any probability mass assigned to topics beyond max_topics); increase max_topics to capture more of the tail.

Parameters:
max_topicsint

Fixed output width – the number of (leading) HDP topic indices to keep. Default: 20.

seedint or None

Random state for reproducible training (gensim’s random_state). Default: 0.

Attributes:
model_gensim.models.HdpModel

The trained HDP model (set by fit).

n_features_int

Vocabulary size seen during fit; transform requires the same width.

Methods

fit(X[, y])

Fit an HDP model to a dense document-term matrix.

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)

Compute (truncated) topic proportions for a dense document-term matrix.

__init__(max_topics=20, seed=0)[source]

Methods

__init__([max_topics, seed])

fit(X[, y])

Fit an HDP model to a dense document-term matrix.

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)

Compute (truncated) topic proportions for a dense document-term matrix.