class_docstr: Calculates absolute metrics for a given dataframe with model scores and
  labels, divided by different values on protected attributes.
  
  Attributes
  ----------
  absolute_metrics : List[str]
      Calculated bias metrics.
  
  Methods
  -------
  get_crosstabs(df, score_thresholds=None, attr_cols=None, score_col="score", label_col="label_value")
      Calculates metrics for a given dataframe.
  get_multimodel_crosstabs(df, score_thresholds=None, attr_cols=None, score_col="score", label_col="label_value")
      Calculates metrics for a given dataframe with multiple models.
class_docstr_tok: ["Calculates","absolute","metrics","for","a","given","dataframe","with","model","scores","and","labels",",","divided","by","different","values","on","protected","attributes",".","Attributes","--","--","--","--","--","absolute_metrics",":","List","[","str","]","Calculated","bias","metrics",".","Methods","--","--","--","-","get_crosstabs","(","df",",","score_thresholds=None",",","attr_cols=None",",","score_col=","''","score","''",",","label_col=","''","label_value","''",")","Calculates","metrics","for","a","given","dataframe",".","get_multimodel_crosstabs","(","df",",","score_thresholds=None",",","attr_cols=None",",","score_col=","''","score","''",",","label_col=","''","label_value","''",")","Calculates","metrics","for","a","given","dataframe","with","multiple","models","."]
docstr: Performs `get_crosstabs()` and calculates group metrics for results
  from multiple models.
  
  Parameters
  ----------
  df: pandas.DataFrame
      Results of model classification. Must contain:
      [score_col,  label_col, "model_id"].
  score_thresholds: Dict[str, List[Union[int, float]]]
      The possible thresholds of the models.
      Accepted keys:
          - 'rank_abs' for absolute ranking (top k scores classified as
             positive).
          - 'rank_pct' for percentage ranking (top X% classified as
             positive).
          - 'score_val' for value threshold (Scores above Y classified as
             positive).
      The values for each key represent the different tested thresholds.
      These must be inside a list.
      If not specified, it is assumed the scores are already in binary
      form.
  attr_cols: List[str]
      Columns with protected attributes. If not specified, all
      columns except 'id', 'model_id', 'entity_id', 'score', 'label_value'
      are used. The values in these columns must be categorical.
  score_col : str
      Column of the dataframe that represents classification result.
      Must be numeric / binary.
  label_col : str
      Column of the dataframe that represents label of instance.
      Values in the column must be binary.
  Returns
  -------
  pandas.DataFrame
      Metrics for each group in the protected attribute, for combination
      of model and threshold. List of protected attributes.
docstr_tok: ["Performs","`","get_crosstabs","(",")","`","and","calculates","group","metrics","for","results","from","multiple","models",".","Parameters","--","--","--","--","--","df",":","pandas.DataFrame","Results","of","model","classification",".","Must","contain",":","[","score_col",",","label_col",",","``","model_id","''","]",".","score_thresholds",":","Dict","[","str",",","List","[","Union","[","int",",","float","]","]","]","The","possible","thresholds","of","the","models",".","Accepted","keys",":","-","'rank_abs","'","for","absolute","ranking","(","top","k","scores","classified","as","positive",")",".","-","'rank_pct","'","for","percentage","ranking","(","top","X","%","classified","as","positive",")",".","-","'score_val","'","for","value","threshold","(","Scores","above","Y","classified","as","positive",")",".","The","values","for","each","key","represent","the","different","tested","thresholds",".","These","must","be","inside","a","list",".","If","not","specified",",","it","is","assumed","the","scores","are","already","in","binary","form",".","attr_cols",":","List","[","str","]","Columns","with","protected","attributes",".","If","not","specified",",","all","columns","except","'id","'",",","'model_id","'",",","'entity_id","'",",","'score","'",",","'label_value'","are","used",".","The","values","in","these","columns","must","be","categorical",".","score_col",":","str","Column","of","the","dataframe","that","represents","classification","result",".","Must","be","numeric","\/","binary",".","label_col",":","str","Column","of","the","dataframe","that","represents","label","of","instance",".","Values","in","the","column","must","be","binary",".","Returns","--","--","--","-","pandas.DataFrame","Metrics","for","each","group","in","the","protected","attribute",",","for","combination","of","model","and","threshold",".","List","of","protected","attributes","."]
code: def get_multimodel_crosstabs(
      self,
      df: pd.DataFrame,
      score_thresholds: Dict[str, List[Union[int, float]]] = None,
      attr_cols: List[str] = None,
      score_col: str = "score",
      label_col: str = "label_value",
  ) -> Tuple[pd.DataFrame, List[str]]:
      """
      Performs `get_crosstabs()` and calculates group metrics for results
      from multiple models.
  
      Parameters
      ----------
      df: pandas.DataFrame
          Results of model classification. Must contain:
          [score_col,  label_col, "model_id"].
      score_thresholds: Dict[str, List[Union[int, float]]]
          The possible thresholds of the models.
          Accepted keys:
              - 'rank_abs' for absolute ranking (top k scores classified as
                 positive).
              - 'rank_pct' for percentage ranking (top X% classified as
                 positive).
              - 'score_val' for value threshold (Scores above Y classified as
                 positive).
          The values for each key represent the different tested thresholds.
          These must be inside a list.
          If not specified, it is assumed the scores are already in binary
          form.
      attr_cols: List[str]
          Columns with protected attributes. If not specified, all
          columns except 'id', 'model_id', 'entity_id', 'score', 'label_value'
          are used. The values in these columns must be categorical.
      score_col : str
          Column of the dataframe that represents classification result.
          Must be numeric / binary.
      label_col : str
          Column of the dataframe that represents label of instance.
          Values in the column must be binary.
      Returns
      -------
      pandas.DataFrame
          Metrics for each group in the protected attribute, for combination
          of model and threshold. List of protected attributes.
      """
      if "model_id" not in df.columns:
          raise ValueError(
              'The method expects a column named "model_id" in the '
              "dataframe."
          )
  
      df_models = df.model_id.unique()
      crosstab_list = []
      model_attr_cols = None
      for model in df_models:
          model_df = df.loc[df["model_id"] == model]
          model_crosstab, model_attr_cols = self.get_crosstabs(
              model_df,
              score_thresholds=score_thresholds,
              attr_cols=attr_cols,
              score_col=score_col,
              label_col=label_col,
          )
          crosstab_list.append(model_crosstab)
      # Note: only returns model_attr_cols from the last iteration, as they
      # all are the same
      return (
          pd.concat(crosstab_list, ignore_index=True),
          model_attr_cols,
      )
  
file_path: aequitas/src/aequitas/group.py
imports: import logging
  import uuid
  from typing import Any, Dict, List, Tuple, Union
  from collections import OrderedDict
  import numpy
  import pandas
  from .bias import Bias
  from .plot import summary, disparity, absolute
label_desc: Use image node_id 4 for calling the Group obj's underlying member method code with example usage: obj.get_multimodel_crosstabs(df, score_thresholds, attr_cols, score_col, label_col) and returns: pd,  model_attr_cols