parquet-converter commited on
Commit
8dc6c87
1 Parent(s): b127233

Update parquet files

Browse files
README.md DELETED
@@ -1,2 +0,0 @@
1
- # Adult
2
- Testing the dataset.
 
 
 
adult.py DELETED
@@ -1,241 +0,0 @@
1
- """Diva: A Fraud Detection Dataset"""
2
-
3
- from typing import List
4
-
5
- import datasets
6
-
7
- import pandas
8
-
9
-
10
- VERSION = datasets.Version("1.0.0")
11
- _ORIGINAL_FEATURE_NAMES = [
12
- "age",
13
- "workclass",
14
- "final_weight",
15
- "education",
16
- "education-num",
17
- "marital_status",
18
- "occupation",
19
- "relationship",
20
- "race",
21
- "sex",
22
- "capital_gain",
23
- "capital_loss",
24
- "hours_per_week",
25
- "native_country",
26
- "threshold"
27
- ]
28
- _BASE_FEATURE_NAMES = [
29
- "age",
30
- "capital_gain",
31
- "capital_loss",
32
- "education",
33
- "final_weight",
34
- "hours_per_week",
35
- "marital_status",
36
- "native_country",
37
- "occupation",
38
- "race",
39
- "relationship",
40
- "sex",
41
- "workclass",
42
- "threshold",
43
- ]
44
- DESCRIPTION = "Adult dataset from the UCI ML repository."
45
- _HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Adult"
46
- _URLS = ("https://huggingface.co/datasets/mstz/adult/raw/adult.csv")
47
- _CITATION = """
48
- @inproceedings{DBLP:conf/kdd/Kohavi96,
49
- author = {Ron Kohavi},
50
- editor = {Evangelos Simoudis and
51
- Jiawei Han and
52
- Usama M. Fayyad},
53
- title = {Scaling Up the Accuracy of Naive-Bayes Classifiers: {A} Decision-Tree
54
- Hybrid},
55
- booktitle = {Proceedings of the Second International Conference on Knowledge Discovery
56
- and Data Mining (KDD-96), Portland, Oregon, {USA}},
57
- pages = {202--207},
58
- publisher = {{AAAI} Press},
59
- year = {1996},
60
- url = {http://www.aaai.org/Library/KDD/1996/kdd96-033.php},
61
- timestamp = {Mon, 05 Jun 2017 13:20:21 +0200},
62
- biburl = {https://dblp.org/rec/conf/kdd/Kohavi96.bib},
63
- bibsource = {dblp computer science bibliography, https://dblp.org}
64
- }"""
65
-
66
- # Dataset info
67
- urls_per_split = {
68
- "train": "https://huggingface.co/datasets/mstz/adult/raw/main/adult_tr.csv",
69
- "test": "https://huggingface.co/datasets/mstz/adult/raw/main/adult_ts.csv"
70
- }
71
- features_types_per_config = {
72
- "income": {"age": datasets.Value("int64"),
73
- "capital_gain": datasets.Value("float64"),
74
- "capital_loss": datasets.Value("float64"),
75
- "education": datasets.Value("int8"),
76
- "final_weight": datasets.Value("int64"),
77
- "hours_per_week": datasets.Value("int64"),
78
- "marital_status": datasets.Value("string"),
79
- "native_country": datasets.Value("string"),
80
- "occupation": datasets.Value("string"),
81
- "race": datasets.Value("string"),
82
- "relationship": datasets.Value("string"),
83
- "sex": datasets.Value("string"),
84
- "workclass": datasets.Value("string"),
85
- "threshold": datasets.ClassLabel(num_classes=2, names=("no", "yes"))},
86
- "income-no race": {"age": datasets.Value("int64"),
87
- "capital_gain": datasets.Value("float64"),
88
- "capital_loss": datasets.Value("float64"),
89
- "education": datasets.Value("int64"),
90
- "final_weight": datasets.Value("int64"),
91
- "hours_per_week": datasets.Value("int64"),
92
- "marital_status": datasets.Value("string"),
93
- "native_country": datasets.Value("string"),
94
- "occupation": datasets.Value("string"),
95
- "relationship": datasets.Value("string"),
96
- "sex": datasets.Value("string"),
97
- "workclass": datasets.Value("string"),
98
- "threshold": datasets.ClassLabel(num_classes=2, names=("no", "yes"))},
99
- "race": {"age": datasets.Value("int64"),
100
- "capital_gain": datasets.Value("float64"),
101
- "capital_loss": datasets.Value("float64"),
102
- "education": datasets.Value("int64"),
103
- "final_weight": datasets.Value("int64"),
104
- "hours_per_week": datasets.Value("int64"),
105
- "marital_status": datasets.Value("string"),
106
- "native_country": datasets.Value("string"),
107
- "occupation": datasets.Value("string"),
108
- "relationship": datasets.Value("string"),
109
- "sex": datasets.Value("string"),
110
- "workclass": datasets.Value("string"),
111
- "over_threshold": datasets.Value("string"),
112
- "race": datasets.ClassLabel(num_classes=5, names=["White", "Black", "Asian-Pac-Islander", "Amer-Indian-Eskimo", "Other"])}
113
- }
114
- features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
115
-
116
-
117
- class AdultConfig(datasets.BuilderConfig):
118
- def __init__(self, **kwargs):
119
- super(AdultConfig, self).__init__(version=VERSION, **kwargs)
120
- self.features = features_per_config[kwargs["name"]]
121
-
122
-
123
- class Adult(datasets.GeneratorBasedBuilder):
124
- # dataset versions
125
- DEFAULT_CONFIG = "income"
126
- BUILDER_CONFIGS = [
127
- AdultConfig(name="income",
128
- description="Adult for income threshold binary classification."),
129
- AdultConfig(name="income-no race",
130
- description="Adult for income threshold binary classification, race excluded from features."),
131
- AdultConfig(name="race",
132
- description="Adult for race (multiclass) classification."),
133
- ]
134
-
135
-
136
- def _info(self):
137
- if self.config.name not in features_per_config:
138
- raise ValueError(f"Unknown configuration: {self.config.name}")
139
-
140
- info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
141
- features=features_per_config[self.config.name])
142
-
143
- return info
144
-
145
- def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
146
- downloads = dl_manager.download_and_extract(urls_per_split)
147
-
148
- return [
149
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
150
- datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"]}),
151
- ]
152
-
153
- def _generate_examples(self, filepath: str):
154
- data = pandas.read_csv(filepath)
155
- data = self.preprocess(data, config=self.config.name)
156
-
157
- for row_id, row in data.iterrows():
158
- data_row = dict(row)
159
-
160
- yield row_id, data_row
161
-
162
- def preprocess(self, data: pandas.DataFrame, config: str = "income") -> pandas.DataFrame:
163
- data.drop("education", axis="columns", inplace=True)
164
- data = data[["age", "capital_gain", "capital_loss", "education-num", "final_weight",
165
- "hours_per_week", "marital_status", "native_country", "occupation",
166
- "race", "relationship", "sex", "workclass", "threshold"]]
167
- data.columns = _BASE_FEATURE_NAMES
168
-
169
- # binarize features
170
- data.loc[:, "sex"] = data.sex.apply(self.encode_sex)
171
-
172
- if config == "income":
173
- return self.income_preprocessing(data)
174
- elif config == "income-no race":
175
- return self.income_norace_preprocessing(data)
176
- elif config =="race":
177
- return self.race_preprocessing(data)
178
- else:
179
- raise ValueError(f"Unknown config: {config}")
180
-
181
- def income_preprocessing(self, data: pandas.DataFrame) -> pandas.DataFrame:
182
- data = data[list(features_types_per_config["income"].keys())]
183
-
184
- return data
185
-
186
- def income_norace_preprocessing(self, data: pandas.DataFrame) -> pandas.DataFrame:
187
- data = data[list(features_types_per_config["income-no race"].keys())]
188
-
189
- return data
190
-
191
- def race_preprocessing(self, data: pandas.DataFrame) -> pandas.DataFrame:
192
- features = list(features_types_per_config["race"].keys())
193
- features[features.index("over_threshold")] = "threshold"
194
- data.loc[:, "race"] = data.race.apply(self.encode_race)
195
- data = data[features]
196
- data.columns = ["age", "capital_gain", "capital_loss", "education", "final_weight",
197
- "hours_per_week", "marital_status", "native_country", "occupation", "relationship", "sex", "workclass", "over_threshold", "race"]
198
-
199
- return data
200
-
201
- def encode_race(self, race):
202
- return self.race_encoding_dic()[race]
203
-
204
- def decode_race(self, code):
205
- return self.race_decoding_dic()[code]
206
-
207
- def race_decoding_dic(self):
208
- return {
209
- 0: "White",
210
- 1: "Black",
211
- 2: "Asian-Pac-Islander",
212
- 3: "Amer-Indian-Eskimo",
213
- 4: "Other",
214
- }
215
-
216
- def race_encoding_dic(self):
217
- return {
218
- "White": 0,
219
- "Black": 1,
220
- "Asian-Pac-Islander": 2,
221
- "Amer-Indian-Eskimo": 3,
222
- "Other": 4,
223
- }
224
-
225
- def encode_sex(self, sex):
226
- return self.sex_encoding_dic()[sex]
227
-
228
- def decode_sex(self, code):
229
- return self.sex_decoding_dic()[code]
230
-
231
- def sex_encoding_dic(self):
232
- return {
233
- "Male": 0,
234
- "Female": 1
235
- }
236
-
237
- def sex_decoding_dic(self):
238
- return {
239
- 0: "Male",
240
- 1: "Female"
241
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adult_tr.csv DELETED
The diff for this file is too large to render. See raw diff
 
adult_ts.csv DELETED
The diff for this file is too large to render. See raw diff
 
income-no race/adult-test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:953682b5689aad5109cbe3a437b8ce44c21fdf2e038317f69813f4c8829d1c92
3
+ size 205111
income-no race/adult-train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d73d5529cc81d2b8e63c7a71514116a7afb0bf44af5c88c51b7206fcdbd52f01
3
+ size 598338
income/adult-test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5decaf638c13bfbc856614e2c594d9d2add6bcc2b0f979acd4337a474053aea1
3
+ size 212460
income/adult-train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25ac33ca303f6dad6978854d5da5e60322927602a72f1a1a687d7463b684f739
3
+ size 619511
race/adult-test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:414e429181c8a27cbbd632aa62ab127fd32619dad5c1d326d4f766c14fa0a963
3
+ size 212056
race/adult-train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e736f44a2e8485120172adb06080b325124bf2391f9870094b5cf7a46e9e2502
3
+ size 618124