mstz commited on
Commit
68f3843
·
1 Parent(s): ce9fbef

Upload adult.py

Browse files
Files changed (1) hide show
  1. adult.py +9 -1
adult.py CHANGED
@@ -130,8 +130,15 @@ class Adult(datasets.GeneratorBasedBuilder):
130
  AdultConfig(name="income-no race",
131
  description="Adult for income threshold binary classification, race excluded from features."),
132
  AdultConfig(name="race",
133
- description="Adult for race multiclass classification."),
134
  ]
 
 
 
 
 
 
 
135
 
136
  def _info(self):
137
  if self.config.name not in features_per_config:
@@ -191,6 +198,7 @@ class Adult(datasets.GeneratorBasedBuilder):
191
  features = list(features_types_per_config["race"].keys())
192
  features[features.index("over_threshold")] = "threshold"
193
  data.loc[:, "over_threshold"] = data.sex.apply(str)
 
194
  data = data[features]
195
  data.columns = ["age", "capital_gain", "capital_loss", "education", "final_weight",
196
  "hours_per_week", "marital_status", "native_country", "occupation", "relationship", "sex", "workclass", "over_threshold", "race"]
 
130
  AdultConfig(name="income-no race",
131
  description="Adult for income threshold binary classification, race excluded from features."),
132
  AdultConfig(name="race",
133
+ description="Adult for race (multiclass) classification."),
134
  ]
135
+ race_encoder = {
136
+ "White": 0,
137
+ "Black": 1,
138
+ "Asian-Pac-Islander": 2,
139
+ "Amer-Indian-Eskimo": 3,
140
+ "Other": 4,
141
+ }
142
 
143
  def _info(self):
144
  if self.config.name not in features_per_config:
 
198
  features = list(features_types_per_config["race"].keys())
199
  features[features.index("over_threshold")] = "threshold"
200
  data.loc[:, "over_threshold"] = data.sex.apply(str)
201
+ data.loc[:, "race"] = data.sex.apply(lambda x: race_encoder[x])
202
  data = data[features]
203
  data.columns = ["age", "capital_gain", "capital_loss", "education", "final_weight",
204
  "hours_per_week", "marital_status", "native_country", "occupation", "relationship", "sex", "workclass", "over_threshold", "race"]