(doc_term_matrix: sp.csr_matrix)
return ics
Compute information content for all terms in a document-term matrix. IC is a
    float in [0.0, 1.0], defined as ``-df * log2(df) - (1 - df) * log2(1 - df)``,
    where df is a term's normalized document frequency.

    Args:
        doc_term_matrix: M x N sparse matrix, where M is the # of docs and
            N is the # of unique terms.

            .. note:: Weighting on the terms doesn't matter! Could be binary or
               tf or tfidf, a term's information content will be the same.

    Returns:
        Array of term information content values, with length equal to
        the # of unique terms (# of columns) in ``doc_term_matrix``.

    Raises:
        ValueError: if ``doc_term_matrix`` doesn't have any non-zero entries.
Compute information content for all terms in a document-term matrix. IC is a
    float in [0.0, 1.0], defined as ``-df * log2(df) - (1 - df) * log2(1 - df)``,
    where df is a term's normalized document frequency.
Compute information content for all terms in a document - term matrix . IC is a float in [ 0 . 0 1 . 0 ] defined as - df * log2 ( df ) - ( 1 - df ) * log2 ( 1 - df ) where df is a term s normalized document frequency .
def get_information_content(doc_term_matrix: sp.csr_matrix) -> np.ndarray:
    """
    Compute information content for all terms in a document-term matrix. IC is a
    float in [0.0, 1.0], defined as ``-df * log2(df) - (1 - df) * log2(1 - df)``,
    where df is a term's normalized document frequency.

    Args:
        doc_term_matrix: M x N sparse matrix, where M is the # of docs and
            N is the # of unique terms.

            .. note:: Weighting on the terms doesn't matter! Could be binary or
               tf or tfidf, a term's information content will be the same.

    Returns:
        Array of term information content values, with length equal to
        the # of unique terms (# of columns) in ``doc_term_matrix``.

    Raises:
        ValueError: if ``doc_term_matrix`` doesn't have any non-zero entries.
    """
    dfs = get_doc_freqs(doc_term_matrix)
    # normalize doc freqs by total number of docs
    # TODO: is this *really* what we want to do?
    dfs = dfs / doc_term_matrix.shape[0]
    ics = -dfs * np.log2(dfs) - (1 - dfs) * np.log2(1 - dfs)
    ics[np.isnan(ics)] = 0.0  # NaN values not permitted!
    return ics
def get_information_content ( doc_term_matrix : sp . csr_matrix ) -> np . ndarray : dfs = get_doc_freqs ( doc_term_matrix ) # normalize doc freqs by total number of docs # TODO: is this *really* what we want to do? dfs = dfs / doc_term_matrix . shape [ 0 ] ics = - dfs * np . log2 ( dfs ) - ( 1 - dfs ) * np . log2 ( 1 - dfs ) ics [ np . isnan ( ics ) ] = 0.0 # NaN values not permitted! return ics