code: def plot_labelled_text_stats(cls, labelled_stats, all_stats):
      import operator
  
      labelled_stats_table = []
  
      for _class in list(labelled_stats.keys())[:5]:
          record = {"class": _class}
          _stats = labelled_stats[_class]
          record["total count"] = _stats.total_count
          plt.figure(figsize=(16, 4))
          plt.subplot(121)
          tfidf = sorted(
              _stats.tfidf.items(),
              key=operator.itemgetter(1),
              reverse=True,
          )[:20]
          words = [item[0] for item in tfidf][::-1]
          scores = [item[1] for item in tfidf][::-1]
          plt.barh(width=scores, y=words)
          plt.title("Average TFIDF\nclass:%s" % _class)
          plt.subplot(122)
          tf = sorted(
              _stats.term_frequency.items(),
              key=operator.itemgetter(1),
              reverse=True,
          )[:20]
          words = [item[0] for item in tf][::-1]
          count = [item[1] for item in tf][::-1]
          plt.barh(width=count, y=words)
          plt.title("Overall Term Frequency\nclass: %s" % _class)
          for pattern, count in _stats.pattern_stats.items():
              record["%s (term count)" % pattern] = count[0]
              record["%s (doc count)" % pattern] = count[1]
          record["longest doc"] = max(list(_stats.word_count.keys()))
          labelled_stats_table.append(record)
  
      plt.figure(figsize=(16, 4))
      plt.subplot(121)
      tfidf = sorted(
          all_stats.tfidf.items(),
          key=operator.itemgetter(1),
          reverse=True,
      )[:20]
      words = [item[0] for item in tfidf][::-1]
      scores = [item[1] for item in tfidf][::-1]
      plt.barh(width=scores, y=words)
      plt.title("Average TFIDF\nall class")
      plt.subplot(122)
      tf = sorted(
          all_stats.term_frequency.items(),
          key=operator.itemgetter(1),
          reverse=True,
      )[:20]
      words = [item[0] for item in tf][::-1]
      count = [item[1] for item in tf][::-1]
      plt.barh(width=count, y=words)
      plt.title("Overall Term Frequency\nall class")
      plt.show()
      record = {"class": "all"}
      record["total count"] = all_stats.total_count
      for pattern, count in all_stats.pattern_stats.items():
          record["%s (term count)" % pattern] = count[0]
          record["%s (doc count)" % pattern] = count[1]
      record["longest doc"] = max(list(all_stats.word_count.keys()))
      labelled_stats_table.append(record)
  
      _stats_df = pd.DataFrame.from_records(labelled_stats_table)
      display(_stats_df)
  
file_path: contextual-ai/xai/plots/data_stats_notebook_plots.py
imports: from collections import Counter
  import matplotlib.pyplot
  import pandas
  import numpy
  import seaborn
  from IPython.display import display, Markdown
label_desc: Use image node_id 8 for calling the NotebookPlots obj's underlying member method code with example usage: obj.plot_labelled_text_stats(cls, labelled_stats, all_stats) without return types