gensim logo

gensim tagline

Get Expert Help From The Gensim Authors

Consulting in Machine Learning & NLP

• Commercial document similarity engine:

Corporate trainings in Python Data Science and Deep Learning

sklearn_api.rpmodel – Scikit learn wrapper for Random Projection model

sklearn_api.rpmodel – Scikit learn wrapper for Random Projection model

Scikit learn interface for gensim for easy use of gensim with scikit-learn Follows scikit-learn API conventions

class gensim.sklearn_api.rpmodel.RpTransformer(id2word=None, num_topics=300)

Bases: sklearn.base.TransformerMixin, sklearn.base.BaseEstimator

Base RP module

Sklearn wrapper for RP model. See gensim.models.RpModel for parameter details.

fit(X, y=None)

Fit the model according to the given training data. Calls gensim.models.RpModel

fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

  • X (numpy array of shape [n_samples, n_features]) – Training set.
  • y (numpy array of shape [n_samples]) – Target values.

X_new – Transformed array.

Return type:

numpy array of shape [n_samples, n_features_new]


Get parameters for this estimator.

Parameters:deep (boolean, optional) – If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:params – Parameter names mapped to their values.
Return type:mapping of string to any

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Return type:self

Take documents/corpus as input. Return RP representation of the input documents/corpus. The input docs can correspond to multiple documents like [[(0, 1.0), (1, 1.0), (2, 1.0)], [(0, 1.0), (3, 1.0), (4, 1.0), (5, 1.0), (6, 1.0), (7, 1.0)]] or a single document like : [(0, 1.0), (1, 1.0), (2, 1.0)]