code: def adult(display=False, n_points=None):
      """Return the Adult census data in a nice package."""
      dtypes = [
          ("Age", "float32"),
          ("Workclass", "category"),
          ("fnlwgt", "float32"),
          ("Education", "category"),
          ("Education-Num", "float32"),
          ("Marital Status", "category"),
          ("Occupation", "category"),
          ("Relationship", "category"),
          ("Race", "category"),
          ("Sex", "category"),
          ("Capital Gain", "float32"),
          ("Capital Loss", "float32"),
          ("Hours per week", "float32"),
          ("Country", "category"),
          ("Target", "category"),
      ]
      raw_data = pd.read_csv(
          cache(github_data_url + "adult.data"),
          names=[d[0] for d in dtypes],
          na_values="?",
          dtype=dict(dtypes),
      )
  
      if n_points is not None:
          raw_data = shap.utils.sample(
              raw_data, n_points, random_state=0
          )
  
      data = raw_data.drop(
          ["Education"], axis=1
      )  # redundant with Education-Num
      filt_dtypes = list(
          filter(lambda x: x[0] not in ["Target", "Education"], dtypes)
      )
      data["Target"] = data["Target"] == " >50K"
      rcode = {
          "Not-in-family": 0,
          "Unmarried": 1,
          "Other-relative": 2,
          "Own-child": 3,
          "Husband": 4,
          "Wife": 5,
      }
      for k, dtype in filt_dtypes:
          if dtype == "category":
              if k == "Relationship":
                  data[k] = np.array(
                      [rcode[v.strip()] for v in data[k]]
                  )
              else:
                  data[k] = data[k].cat.codes
  
      if display:
          return (
              raw_data.drop(["Education", "Target", "fnlwgt"], axis=1),
              data["Target"].values,
          )
      return (
          data.drop(["Target", "fnlwgt"], axis=1),
          data["Target"].values,
      )
  
file_path: shap/shap/datasets.py
imports: import os
  from urllib.request import urlretrieve
  import numpy
  import pandas
  import sklearn.datasets
  import shap
label_desc: Use image node_id 8 for calling a global function with example usage: adult(display, n_points) and returns: data,  data, raw_data,  data