docstr: Parameters
  ----------
  term_doc_matrix : TermDocMatrix
      Term document matrix object to compact
  non_text : bool
      Use non-text features instead of terms
  
  Returns
  -------
  New term doc matrix
docstr_tok: ["Parameters","--","--","--","--","--","term_doc_matrix",":","TermDocMatrix","Term","document","matrix","object","to","compact","non_text",":","bool","Use","non-text","features","instead","of","terms","Returns","--","--","--","-","New","term","doc","matrix"]
code: def compact(self, term_doc_matrix, non_text=False):
      """
      Parameters
      ----------
      term_doc_matrix : TermDocMatrix
          Term document matrix object to compact
      non_text : bool
          Use non-text features instead of terms
  
      Returns
      -------
      New term doc matrix
      """
      pmi_df = self.get_pmi_df(term_doc_matrix, non_text)
  
      threshold_df = self._get_ngram_length_pmi_thresholds(pmi_df)
  
      filtered_pmi_df = pd.merge(
          pmi_df, threshold_df, left_on="Len", right_index=True
      )[lambda df: df.NPMI < df.NPMIThreshold]
  
      terms_to_remove = list(filtered_pmi_df.Term)
  
      return term_doc_matrix.remove_terms(
          terms_to_remove, non_text
      ).remove_infrequent_words(
          self.minimum_term_count - 1,
          term_ranker=self.term_ranker,
          non_text=non_text,
      )
  
file_path: scattertext/scattertext/termcompaction/npmi_compactor.py
imports: import numpy
  import pandas
  from tqdm.auto import tqdm
  from scattertext.termranking.TermRanker import TermRanker
  from scattertext.termranking.AbsoluteFrequencyRanker import AbsoluteFrequencyRanker
label_desc: Use image node_id 2 for calling the NPMICompactor obj's underlying member method code with example usage: obj.compact(term_doc_matrix, non_text) and returns: term_doc_matrix