(doc_term_matrix: sp.csr_matrix)
return np.bincount(doc_term_matrix.indices, minlength=n_terms)
Compute document frequencies for all terms in a document-term matrix.

    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 doc freq will be the same.

    Returns:
        Array of document frequencies, with length equal to the # of unique terms
        (i.e. # of columns) in ``doc_term_matrix``.

    Raises:
        ValueError: if ``doc_term_matrix`` doesn't have any non-zero entries.
Compute document frequencies for all terms in a document-term matrix.
Compute document frequencies for all terms in a document - term matrix .
def get_doc_freqs(doc_term_matrix: sp.csr_matrix) -> np.ndarray:
    """
    Compute document frequencies for all terms in a document-term matrix.

    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 doc freq will be the same.

    Returns:
        Array of document frequencies, with length equal to the # of unique terms
        (i.e. # of columns) in ``doc_term_matrix``.

    Raises:
        ValueError: if ``doc_term_matrix`` doesn't have any non-zero entries.
    """
    if doc_term_matrix.nnz == 0:
        raise ValueError("`doc_term_matrix` must have at least 1 non-zero entry")
    _, n_terms = doc_term_matrix.shape
    return np.bincount(doc_term_matrix.indices, minlength=n_terms)
def get_doc_freqs ( doc_term_matrix : sp . csr_matrix ) -> np . ndarray : if doc_term_matrix . nnz == 0 : raise ValueError ( "`doc_term_matrix` must have at least 1 non-zero entry" ) _ , n_terms = doc_term_matrix . shape return np . bincount ( doc_term_matrix . indices , minlength = n_terms )