Datasets:
Upload adult.py
Browse files
adult.py
CHANGED
@@ -69,7 +69,7 @@ urls_per_split = {
|
|
69 |
"test": "https://huggingface.co/datasets/mstz/adult/raw/main/adult_ts.csv"
|
70 |
}
|
71 |
features_types_per_config = {
|
72 |
-
"income": datasets.Features({
|
73 |
"capital_gain": datasets.Value("float64"),
|
74 |
"capital_loss": datasets.Value("float64"),
|
75 |
"education": datasets.Value("int8"),
|
@@ -158,7 +158,6 @@ class Adult(datasets.GeneratorBasedBuilder):
|
|
158 |
]
|
159 |
|
160 |
def _generate_examples(self, filepath: str):
|
161 |
-
print(f"generating for {filepath}")
|
162 |
data = pandas.read_csv(filepath)
|
163 |
data = self.preprocess(data, config=self.config.name)
|
164 |
|
@@ -169,9 +168,7 @@ class Adult(datasets.GeneratorBasedBuilder):
|
|
169 |
|
170 |
def preprocess(self, data: pandas.DataFrame, config: str = "income") -> pandas.DataFrame:
|
171 |
data.drop("education", axis="columns", inplace=True)
|
172 |
-
|
173 |
-
data = data[[#"age",
|
174 |
-
"capital_gain", "capital_loss", "education-num", "final_weight",
|
175 |
"hours_per_week", "marital_status", "native_country", "occupation",
|
176 |
"race", "relationship", "sex", "workclass", "threshold"]]
|
177 |
data.columns = _BASE_FEATURE_NAMES[1:]
|
|
|
69 |
"test": "https://huggingface.co/datasets/mstz/adult/raw/main/adult_ts.csv"
|
70 |
}
|
71 |
features_types_per_config = {
|
72 |
+
"income": datasets.Features({"age": datasets.Value("int64"),
|
73 |
"capital_gain": datasets.Value("float64"),
|
74 |
"capital_loss": datasets.Value("float64"),
|
75 |
"education": datasets.Value("int8"),
|
|
|
158 |
]
|
159 |
|
160 |
def _generate_examples(self, filepath: str):
|
|
|
161 |
data = pandas.read_csv(filepath)
|
162 |
data = self.preprocess(data, config=self.config.name)
|
163 |
|
|
|
168 |
|
169 |
def preprocess(self, data: pandas.DataFrame, config: str = "income") -> pandas.DataFrame:
|
170 |
data.drop("education", axis="columns", inplace=True)
|
171 |
+
data = data[["age", "capital_gain", "capital_loss", "education-num", "final_weight",
|
|
|
|
|
172 |
"hours_per_week", "marital_status", "native_country", "occupation",
|
173 |
"race", "relationship", "sex", "workclass", "threshold"]]
|
174 |
data.columns = _BASE_FEATURE_NAMES[1:]
|