(preprocess=False)
Fetch the `compas-two-years`_ dataset, also known as ProPublica recidivism, from GitHub and add `fairness_info`.

    It contains information about individuals with a binary
    classification for recidivism, indicating whether they were
    re-arrested within two years after the first arrest. Without
    preprocessing, the dataset has 6,172 rows and 51 columns.  There
    are two protected attributes, sex and race, and the disparate
    impact is 0.75.  The data includes numeric and categorical columns, with some
    missing values.

    .. _`compas-two-years`: https://github.com/propublica/compas-analysis

    Parameters
    ----------
    preprocess : boolean, optional, default False

      If True,
      encode protected attributes in X as 0 or 1 to indicate privileged groups
      (1 if Female or Caucasian for the corresponding sex and race columns respectively);
      and apply one-hot encoding to any remaining features in X that
      are categorical and not protected attributes.

    Returns
    -------
    result : tuple

      - item 0: pandas Dataframe

          Features X, including both protected and non-protected attributes.

      - item 1: pandas Series

          Labels y.

      - item 3: fairness_info

          JSON meta-data following the format understood by fairness metrics
          and mitigation operators in `lale.lib.aif360`.
Fetch the `compas-two-years`_ dataset, also known as ProPublica recidivism, from GitHub and add `fairness_info`.
Fetch the compas - two - years _ dataset also known as ProPublica recidivism from GitHub and add fairness_info .
def fetch_compas_df(preprocess=False):
    """
    Fetch the `compas-two-years`_ dataset, also known as ProPublica recidivism, from GitHub and add `fairness_info`.

    It contains information about individuals with a binary
    classification for recidivism, indicating whether they were
    re-arrested within two years after the first arrest. Without
    preprocessing, the dataset has 6,172 rows and 51 columns.  There
    are two protected attributes, sex and race, and the disparate
    impact is 0.75.  The data includes numeric and categorical columns, with some
    missing values.

    .. _`compas-two-years`: https://github.com/propublica/compas-analysis

    Parameters
    ----------
    preprocess : boolean, optional, default False

      If True,
      encode protected attributes in X as 0 or 1 to indicate privileged groups
      (1 if Female or Caucasian for the corresponding sex and race columns respectively);
      and apply one-hot encoding to any remaining features in X that
      are categorical and not protected attributes.

    Returns
    -------
    result : tuple

      - item 0: pandas Dataframe

          Features X, including both protected and non-protected attributes.

      - item 1: pandas Series

          Labels y.

      - item 3: fairness_info

          JSON meta-data following the format understood by fairness metrics
          and mitigation operators in `lale.lib.aif360`.
    """
    violent_recidivism = False
    _try_download_compas(violent_recidivism=violent_recidivism)
    if preprocess:
        # Odd finding here: "Female" is a privileged class in the dataset, but the original
        # COMPAS algorithm actually predicted worse outcomes for that class after controlling
        # for other factors. Leaving it as "Female" for now (AIF360 does this by default as well)
        # but potentially worthy of revisiting.
        # See https://www.propublica.org/article/how-we-analyzed-the-compas-recidivism-algorithm
        # and https://github.com/propublica/compas-analysis/blob/master/Compas%20Analysis.ipynb
        # (hunch is that COMPAS was trained on more biased data that is not reproduced in ProPublica's dataset)
        dataset = load_preproc_data_compas()
        # above preprocessing results in a WARNING of "Missing Data: 5 rows removed from CompasDataset."
        # unclear how to resolve at the moment
        return _get_pandas_and_fairness_info_from_compas_dataset(dataset)
    else:
        return _get_pandas_and_fairness_info_from_compas_csv(
            violent_recidivism=violent_recidivism
        )
def fetch_compas_df ( preprocess = False ) : violent_recidivism = False _try_download_compas ( violent_recidivism = violent_recidivism ) if preprocess : # Odd finding here: "Female" is a privileged class in the dataset, but the original # COMPAS algorithm actually predicted worse outcomes for that class after controlling # for other factors. Leaving it as "Female" for now (AIF360 does this by default as well) # but potentially worthy of revisiting. # See https://www.propublica.org/article/how-we-analyzed-the-compas-recidivism-algorithm # and https://github.com/propublica/compas-analysis/blob/master/Compas%20Analysis.ipynb # (hunch is that COMPAS was trained on more biased data that is not reproduced in ProPublica's dataset) dataset = load_preproc_data_compas ( ) # above preprocessing results in a WARNING of "Missing Data: 5 rows removed from CompasDataset." # unclear how to resolve at the moment return _get_pandas_and_fairness_info_from_compas_dataset ( dataset ) else : return _get_pandas_and_fairness_info_from_compas_csv ( violent_recidivism = violent_recidivism )