docstr: Conditioned on the current subsets of values for all other attributes,
  compute the summed outcome (observed_sum = \sum_i y_i) and all expectations p_i
  for each value of the current attribute.
  Also use additive linear-time subset scanning to compute the set of distinct thresholds
  for which different subsets of attribute values have positive scores. Note that the number
  of such thresholds will be linear rather than exponential in the arity of the attribute.
  
  :param coordinates: data frame containing having as columns the covariates/features
  :param expectations: data series containing the expectations/expected outcomes
  :param outcomes: data series containing the outcomes/observed outcomes
  :param current_subset: current subset to compute aggregates
  :param column_name: attribute name to scan over
  :param penalty: penalty coefficient
  :return: dictionary of aggregates, sorted thresholds (roots), observed sum of the subset, array of observed
  expectations
docstr_tok: ["Conditioned","on","the","current","subsets","of","values","for","all","other","attributes",",","compute","the","summed","outcome","(","observed_sum","=","\\sum_i","y_i",")","and","all","expectations","p_i","for","each","value","of","the","current","attribute",".","Also","use","additive","linear-time","subset","scanning","to","compute","the","set","of","distinct","thresholds","for","which","different","subsets","of","attribute","values","have","positive","scores",".","Note","that","the","number","of","such","thresholds","will","be","linear","rather","than","exponential","in","the","arity","of","the","attribute",".",":","param","coordinates",":","data","frame","containing","having","as","columns","the","covariates\/features",":","param","expectations",":","data","series","containing","the","expectations\/expected","outcomes",":","param","outcomes",":","data","series","containing","the","outcomes\/observed","outcomes",":","param","current_subset",":","current","subset","to","compute","aggregates",":","param","column_name",":","attribute","name","to","scan","over",":","param","penalty",":","penalty","coefficient",":","return",":","dictionary","of","aggregates",",","sorted","thresholds","(","roots",")",",","observed","sum","of","the","subset",",","array","of","observed","expectations"]
code: def get_aggregates(
      self,
      coordinates: pd.DataFrame,
      outcomes: pd.Series,
      expectations: pd.Series,
      current_subset: dict,
      column_name: str,
      penalty: float,
  ):
      """
      Conditioned on the current subsets of values for all other attributes,
      compute the summed outcome (observed_sum = \sum_i y_i) and all expectations p_i
      for each value of the current attribute.
      Also use additive linear-time subset scanning to compute the set of distinct thresholds
      for which different subsets of attribute values have positive scores. Note that the number
      of such thresholds will be linear rather than exponential in the arity of the attribute.
  
      :param coordinates: data frame containing having as columns the covariates/features
      :param expectations: data series containing the expectations/expected outcomes
      :param outcomes: data series containing the outcomes/observed outcomes
      :param current_subset: current subset to compute aggregates
      :param column_name: attribute name to scan over
      :param penalty: penalty coefficient
      :return: dictionary of aggregates, sorted thresholds (roots), observed sum of the subset, array of observed
      expectations
      """
  
      # compute the subset of records matching the current subgroup along all other dimensions
      # temp_df includes the covariates x_i, outcome y_i, and predicted expectation p_i for each matching record
      if current_subset:
          to_choose = (
              coordinates[current_subset.keys()]
              .isin(current_subset)
              .all(axis=1)
          )
          temp_df = pd.concat(
              [
                  coordinates.loc[to_choose],
                  outcomes[to_choose],
                  expectations[to_choose],
              ],
              axis=1,
          )
      else:
          temp_df = pd.concat(
              [coordinates, outcomes, expectations], axis=1
          )
  
      # these wil be used to keep track of the aggregate values and the distinct thresholds to be considered
      aggregates = {}
      thresholds = set()
  
      scoring_function = self.scoring_function
  
      # consider each distinct value of the given attribute (column_name)
      for name, group in temp_df.groupby(column_name):
          # compute the sum of outcomes \sum_i y_i
          observed_sum = group.iloc[:, -2].sum()
  
          # all expectations p_i
          expectations = group.iloc[:, -1].values
  
          # compute q_min and q_max for the attribute value
          exist, q_mle, q_min, q_max = scoring_function.compute_qs(
              observed_sum, expectations, penalty
          )
  
          # Add to aggregates, and add q_min and q_max to thresholds.
          # Note that thresholds is a set so duplicates will be removed automatically.
          if exist:
              aggregates[name] = {
                  "q_mle": q_mle,
                  "q_min": q_min,
                  "q_max": q_max,
                  "observed_sum": observed_sum,
                  "expectations": expectations,
              }
              thresholds.update([q_min, q_max])
  
      # We also keep track of the summed outcomes \sum_i y_i and the expectations p_i for the case where _
      # all_ values of that attribute are considered (regardless of whether they contribute positively to score).
      # This is necessary because of the way we compute the penalty term: including all attribute values, equivalent
      # to ignoring the attribute, has the lowest penalty (of 0) and thus we need to score that subset as well.
      all_observed_sum = temp_df.iloc[:, -2].sum()
      all_expectations = temp_df.iloc[:, -1].values
  
      return [
          aggregates,
          sorted(thresholds),
          all_observed_sum,
          all_expectations,
      ]
  
file_path: AIF360/aif360/detectors/mdss/MDSS.py
imports: from aif360.detectors.mdss.ScoringFunctions.ScoringFunction import ScoringFunction
  from aif360.detectors.mdss.generator import get_entire_subset, get_random_subset
  from aif360.detectors.mdss.ScoringFunctions import Bernoulli, BerkJones, Gaussian, ScoringFunction, Poisson
  import pandas
  import numpy
label_desc: Use image node_id 2 for calling the MDSS obj's underlying member method code with example usage: obj.get_aggregates(coordinates, outcomes, expectations, current_subset, column_name, penalty) and returns: list