class_docstr: Filter out terms below a particular frequency or pmi threshold.
class_docstr_tok: ["Filter","out","terms","below","a","particular","frequency","or","pmi","threshold","."]
docstr: Parameters
  ----------
  term_doc_matrix  : TermDocMatrix
  
  Returns
  -------
  TermDocMatrix pmi-filterd term doc matrix
docstr_tok: ["Parameters","--","--","--","--","--","term_doc_matrix",":","TermDocMatrix","Returns","--","--","--","-","TermDocMatrix","pmi-filterd","term","doc","matrix"]
code: def filter(self, term_doc_matrix):
      """
      Parameters
      ----------
      term_doc_matrix  : TermDocMatrix
  
      Returns
      -------
      TermDocMatrix pmi-filterd term doc matrix
      """
      df = term_doc_matrix.get_term_freq_df()
      if len(df) == 0:
          return term_doc_matrix
      low_pmi_bigrams = get_low_pmi_bigrams(
          self._threshold_coef, df
      ).index
      infrequent_terms = df[df.sum(axis=1) < self._min_freq].index
      filtered_term_doc_mat = term_doc_matrix.remove_terms(
          set(low_pmi_bigrams | infrequent_terms)
      )
      try:
          filtered_term_doc_mat.get_term_freq_df()
      except ValueError:
          raise AtLeastOneCategoryHasNoTermsException()
      return filtered_term_doc_mat
  
file_path: scattertext/scattertext/TermDocMatrixFilter.py
imports: from collections import Counter
  import numpy
  from scattertext.Common import DEFAULT_PMI_THRESHOLD_COEFFICIENT
label_desc: Use image node_id 2 for calling the TermDocMatrixFilter obj's underlying member method code with example usage: obj.filter(term_doc_matrix) and returns: filtered_term_doc_mat, term_doc_matrix