gensim.models.NormModel
¶
-
class
gensim.models.
NormModel
(corpus=None, norm='l2')[source]¶ Objects of this class realize the explicit normalization of vectors. Supported norms are l1’ and ‘l2’ with ‘l2’ being default.
The main methods are:
- Constructor which normalizes the terms in the given corpus document-wise.
- The normalize() method which normalizes a simple count representation.
- The [] transformation which internally calls the self.normalize() method.
>>> norm_l2 = NormModel(corpus) >>> print(norm_l2[some_doc]) >>> norm_l2.save('/tmp/foo.tfidf_model')
Model persistency is achieved via its load/save methods
Methods¶
__init__ ([corpus, norm]) |
Compute the ‘l1’ or ‘l2’ normalization by normalizing separately for each doc in a corpus. |
calc_norm (corpus) |
Calculates the norm by calling matutils.unitvec with the norm parameter. |
load (fname[, mmap]) |
Load a previously saved object from file (also see save). |
normalize (bow) |
|
save (fname_or_handle[, separately, ...]) |
Save the object to file (also see load). |