Datasets:
Upload compas.py
Browse files
compas.py
CHANGED
|
@@ -205,9 +205,6 @@ class Compas(datasets.GeneratorBasedBuilder):
|
|
| 205 |
def _generate_examples(self, filepath: str):
|
| 206 |
data = pandas.read_csv(filepath)
|
| 207 |
data = self.preprocess(data, config=self.config.name)
|
| 208 |
-
print(data.dtypes)
|
| 209 |
-
print(data.days_before_screening_arrest.unique())
|
| 210 |
-
print(data.days_of_recidividity_after_arrest.unique())
|
| 211 |
|
| 212 |
for row_id, row in data.iterrows():
|
| 213 |
data_row = dict(row)
|
|
@@ -268,8 +265,6 @@ class Compas(datasets.GeneratorBasedBuilder):
|
|
| 268 |
data.drop("in_custody", axis="columns", inplace=True)
|
| 269 |
data.drop("out_custody", axis="columns", inplace=True)
|
| 270 |
|
| 271 |
-
print("data.columns")
|
| 272 |
-
print(data.columns)
|
| 273 |
data = data[["sex",
|
| 274 |
"age",
|
| 275 |
"race",
|
|
@@ -307,6 +302,7 @@ class Compas(datasets.GeneratorBasedBuilder):
|
|
| 307 |
# categorize features
|
| 308 |
print(data.columns)
|
| 309 |
data.loc[:, "race"] = data.race.apply(self.encode_race)
|
|
|
|
| 310 |
|
| 311 |
return data
|
| 312 |
|
|
|
|
| 205 |
def _generate_examples(self, filepath: str):
|
| 206 |
data = pandas.read_csv(filepath)
|
| 207 |
data = self.preprocess(data, config=self.config.name)
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
for row_id, row in data.iterrows():
|
| 210 |
data_row = dict(row)
|
|
|
|
| 265 |
data.drop("in_custody", axis="columns", inplace=True)
|
| 266 |
data.drop("out_custody", axis="columns", inplace=True)
|
| 267 |
|
|
|
|
|
|
|
| 268 |
data = data[["sex",
|
| 269 |
"age",
|
| 270 |
"race",
|
|
|
|
| 302 |
# categorize features
|
| 303 |
print(data.columns)
|
| 304 |
data.loc[:, "race"] = data.race.apply(self.encode_race)
|
| 305 |
+
data.loc[:, "days_of_recidividity_after_arrest"] = data.days_of_recidividity_after_arrest.astype(int)
|
| 306 |
|
| 307 |
return data
|
| 308 |
|