Module Import alias Import alias ImportFrom alias alias alias Assign NameStore Call AttributeLoad NameLoad attr Str ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Dict If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str Assign NameStore Dict Assign TupleStore NameStore NameStore TupleLoad Num Num For TupleStore NameStore NameStore Call NameLoad NameLoad body If CompareEq BinOpMod NameLoad Num Num body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad AugAssignAdd NameStore Call NameLoad NameLoad For TupleStore NameStore NameStore NameLoad body Assign SubscriptStore NameLoad Index NameLoad BinOpAdd Call AttributeLoad NameLoad attr NameLoad Num NameLoad Assign AttributeStore NameLoad attr BinOpAdd NameLoad Num Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str For TupleStore NameStore NameStore Call NameLoad NameLoad body For TupleStore NameStore NameStore NameLoad body Assign NameStore BinOpMult BinOpDiv Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad Call AttributeLoad NameLoad attr BinOpDiv Call NameLoad NameLoad SubscriptLoad NameLoad Index NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad BinOpAdd Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Num NameLoad If CompareNotEq NameLoad NameLoad body Raise Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str For NameStore AttributeLoad NameLoad attr body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad BinOpAdd Num BinOpDiv SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Call AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body Return Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp TupleLoad NameLoad BinOpMult Call AttributeLoad NameLoad attr BinOpAdd NameLoad Num Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad comprehension TupleStore NameStore NameStore NameLoad CompareIn NameLoad AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list
N/A N/A logging N/A math gensim interfaces matutils utils N/A logger N/A N/A logging getLogger gensim.models.logentropy_model LogEntropyModel N/A N/A interfaces TransformationABC N/A N/A 
    Objects of this class realize the transformation between word-document
    co-occurence matrix (integers) into a locally/globally weighted matrix
    (positive floats).

    This is done by a log entropy normalization, optionally normalizing the
    resulting documents to unit length. The following formulas explain how
    to compute the log entropy weight for term `i` in document `j`::

      local_weight_{i,j} = log(frequency_{i,j} + 1)

      P_{i,j} = frequency_{i,j} / sum_j frequency_{i,j}

                            sum_j P_{i,j} * log(P_{i,j})
      global_weight_i = 1 + ----------------------------
                            log(number_of_documents + 1)

      final_weight_{i,j} = local_weight_{i,j} * global_weight_i

    The main methods are:

    1. constructor, which calculates the global weighting for all terms in
        a corpus.
    2. the [] method, which transforms a simple count representation into the
        log entropy normalized space.

    >>> log_ent = LogEntropyModel(corpus)
    >>> print(log_ent[some_doc])
    >>> log_ent.save('/tmp/foo.log_ent_model')

    Model persistency is achieved via its load/save methods.
     __init__ N/A N/A self corpus id2word normalize N/A None True N/A N/A 
        `normalize` dictates whether the resulting vectors will be
        set to unit length.
         N/A N/A self normalize normalize N/A N/A self n_docs 0 N/A N/A self n_words 0 N/A N/A self entr N/A N/A N/A corpus None N/A N/A N/A N/A self initialize corpus N/A __str__ N/A N/A self N/A N/A N/A N/A LogEntropyModel(n_docs=%s, n_words=%s) N/A N/A self n_docs N/A self n_words N/A initialize N/A N/A self corpus N/A N/A N/A 
        Initialize internal statistics based on a training corpus. Called
        automatically from the constructor.
         N/A N/A N/A logger info calculating counts N/A glob_freq N/A N/A N/A glob_num_words doc_no N/A 0 -1 N/A N/A doc_no bow N/A enumerate corpus N/A N/A N/A N/A doc_no 10000 0 N/A N/A N/A N/A logger info N/A PROGRESS: processing document #%i doc_no N/A glob_num_words N/A len bow N/A N/A term_id term_count bow N/A N/A N/A glob_freq N/A term_id N/A N/A N/A glob_freq get term_id 0 term_count N/A N/A self n_docs N/A doc_no 1 N/A N/A self n_words glob_num_words N/A N/A N/A logger info N/A calculating global log entropy weights for %i documents and %i features (%i matrix non-zeros) N/A N/A self n_docs N/A len glob_freq N/A self n_words N/A N/A N/A logger debug iterating over corpus N/A N/A doc_no2 bow N/A enumerate corpus N/A N/A N/A key freq bow N/A N/A p N/A N/A N/A float freq N/A glob_freq N/A key N/A N/A math log N/A N/A float freq N/A glob_freq N/A key N/A N/A N/A self entr N/A key N/A N/A N/A N/A self entr get key 0.0 p N/A N/A doc_no2 doc_no N/A N/A N/A ValueError LogEntropyModel doesn't support generators as training data N/A N/A N/A logger debug iterating over keys N/A key N/A self entr N/A N/A N/A N/A self entr N/A key N/A 1 N/A N/A N/A self entr N/A key N/A N/A math log N/A N/A self n_docs 1 N/A __getitem__ N/A N/A self bow N/A N/A N/A 
        Return log entropy representation of the input vector and/or corpus.
         N/A N/A is_corpus bow N/A N/A utils is_corpus bow N/A is_corpus N/A N/A N/A N/A self _apply bow N/A vector N/A N/A term_id N/A N/A N/A math log N/A tf 1 N/A N/A N/A self entr get term_id N/A N/A term_id tf bow N/A term_id N/A self entr N/A N/A self normalize N/A N/A vector N/A N/A matutils unitvec vector N/A vector N/A N/A