class_docstr: Main class for executing Sentiment Solution pipeline.
  
  Args:
      anonymiser (Anonymiser, optional): Method to anonymise events' text.
      max_events (int, optional): Maximum number of events to show for each aspect-polarity pair.
class_docstr_tok: ["Main","class","for","executing","Sentiment","Solution","pipeline",".","Args",":","anonymiser","(","Anonymiser",",","optional",")",":","Method","to","anonymise","events","'","text",".","max_events","(","int",",","optional",")",":","Maximum","number","of","events","to","show","for","each","aspect-polarity","pair","."]
docstr: Aggregates counts for each aspect-polarity pairs, with separate counts for in-domain
  only events.
docstr_tok: ["Aggregates","counts","for","each","aspect-polarity","pairs",",","with","separate","counts","for","in-domain","only","events","."]
code: def _compute_stats(
      self, results: dict, aspects: list, opinion_lex: dict
  ) -> pd.DataFrame:
      """Aggregates counts for each aspect-polarity pairs, with separate counts for in-domain
      only events.
      """
      index = pd.MultiIndex.from_product(
          [aspects, ["POS", "NEG"], [False, True]],
          names=["Aspect", "Polarity", "inDomain"],
      )
      stats = pd.DataFrame(columns=["Quantity", "Score"], index=index)
      stats[["Quantity", "Score"]] = stats[
          ["Quantity", "Score"]
      ].fillna(0)
      stats = stats.sort_index()
      scores = stats.copy()
  
      for doc in tqdm(results.values()):
          for sent in doc.sentences:
              for event in sent.events:
                  aspect = [
                      t for t in event if t.type == TermType.ASPECT
                  ][0]
                  opinion = [
                      t for t in event if t.type == TermType.OPINION
                  ][0]
                  score = aspect.score
                  key = aspect.text, aspect.polarity.name
                  count = self._add_event(stats, key, False, score)
                  in_domain = opinion_lex[
                      opinion.text.lower()
                  ].is_acquired
                  count_dom = (
                      self._add_event(stats, key, True, score)
                      if in_domain
                      else -1
                  )
  
                  if count <= self.max_events:
                      sent_ui = _ui_format(sent, doc)
                      self._add_sentence(
                          sent_ui,
                          stats,
                          scores,
                          key,
                          False,
                          count,
                          score,
                      )
                      if in_domain:
                          self._add_sentence(
                              sent_ui,
                              stats,
                              scores,
                              key,
                              True,
                              count_dom,
                              score,
                          )
      for key in index:  # sort sentences according to their scores
          stats.loc[key, 2:] = stats.loc[key][2:][
              np.argsort(scores.loc[key][2:])
          ].tolist()
      return stats
  
imports: import argparse
  import json
  from os import PathLike
  from os.path import isdir
  from typing import Optional
  import csv
  import re
  from abc import abstractmethod
  import numpy
  import pandas
  from tqdm import tqdm
  from nlp_architect import LIBRARY_OUT
  from nlp_architect.common.core_nlp_doc import CoreNLPDoc
  from nlp_architect.models.absa.inference.data_types import TermType, SentimentDocEncoder, SentimentDoc, SentimentSentence
  from nlp_architect.models.absa.inference.inference import SentimentInference
  from nlp_architect.models.absa.utils import load_opinion_lex
  from nlp_architect.utils.io import walk_directory, validate_existing_filepath, validate_existing_directory, validate_existing_path, line_count
label_desc: Use image node_id 4 for calling the SentimentSolution obj's underlying member method code with example usage: obj._compute_stats(results, aspects, opinion_lex) and returns: stats