Datasets:
Upload 3 files
Browse files- .gitattributes +1 -0
- README.md +14 -1
- uscensus.py +217 -0
- uscensus1990.csv +3 -0
.gitattributes
CHANGED
@@ -52,3 +52,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
52 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
55 |
+
uscensus1990.csv filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- uscensus
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
- UCI
|
9 |
+
pretty_name: Uscensus
|
10 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
11 |
+
- tabular-classification
|
12 |
+
configs:
|
13 |
+
- uscensus
|
14 |
---
|
15 |
+
# Uscensus
|
16 |
+
[US census dataset]() from [UCI]().
|
uscensus.py
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Uscensus Dataset"""
|
2 |
+
|
3 |
+
from typing import List
|
4 |
+
from functools import partial
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
import pandas
|
9 |
+
|
10 |
+
|
11 |
+
VERSION = datasets.Version("1.0.0")
|
12 |
+
|
13 |
+
_ENCODING_DICS = {}
|
14 |
+
_BASE_FEATURE_NAMES = [
|
15 |
+
"caseid",
|
16 |
+
"dAge",
|
17 |
+
"dAncstry1",
|
18 |
+
"dAncstry2",
|
19 |
+
"iAvail",
|
20 |
+
"iCitizen",
|
21 |
+
"iClass",
|
22 |
+
"dDepart",
|
23 |
+
"iDisabl1",
|
24 |
+
"iDisabl2",
|
25 |
+
"iEnglish",
|
26 |
+
"iFeb55",
|
27 |
+
"iFertil",
|
28 |
+
"dHispanic",
|
29 |
+
"dHour89",
|
30 |
+
"dHours",
|
31 |
+
"iImmigr",
|
32 |
+
"dIncome1",
|
33 |
+
"dIncome2",
|
34 |
+
"dIncome3",
|
35 |
+
"dIncome4",
|
36 |
+
"dIncome5",
|
37 |
+
"dIncome6",
|
38 |
+
"dIncome7",
|
39 |
+
"dIncome8",
|
40 |
+
"dIndustry",
|
41 |
+
"iKorean",
|
42 |
+
"iLang1",
|
43 |
+
"iLooking",
|
44 |
+
"iMarital",
|
45 |
+
"iMay75880",
|
46 |
+
"iMeans",
|
47 |
+
"iMilitary",
|
48 |
+
"iMobility",
|
49 |
+
"iMobillim",
|
50 |
+
"dOccup",
|
51 |
+
"iOthrserv",
|
52 |
+
"iPerscare",
|
53 |
+
"dPOB",
|
54 |
+
"dPoverty",
|
55 |
+
"dPwgt1",
|
56 |
+
"iRagechld",
|
57 |
+
"dRearning",
|
58 |
+
"iRelat1",
|
59 |
+
"iRelat2",
|
60 |
+
"iRemplpar",
|
61 |
+
"iRiders",
|
62 |
+
"iRlabor",
|
63 |
+
"iRownchld",
|
64 |
+
"dRpincome",
|
65 |
+
"iRPOB",
|
66 |
+
"iRrelchld",
|
67 |
+
"iRspouse",
|
68 |
+
"iRvetserv",
|
69 |
+
"iSchool",
|
70 |
+
"iSept80",
|
71 |
+
"iSex",
|
72 |
+
"iSubfam1",
|
73 |
+
"iSubfam2",
|
74 |
+
"iTmpabsnt",
|
75 |
+
"dTravtime",
|
76 |
+
"iVietnam",
|
77 |
+
"dWeek89",
|
78 |
+
"iWork89",
|
79 |
+
"iWorklwk",
|
80 |
+
"iWWII",
|
81 |
+
"iYearsch",
|
82 |
+
"iYearwrk",
|
83 |
+
"dYrsserv",
|
84 |
+
]
|
85 |
+
|
86 |
+
DESCRIPTION = "Uscensus dataset."
|
87 |
+
_HOMEPAGE = ""
|
88 |
+
_URLS = ("")
|
89 |
+
_CITATION = """"""
|
90 |
+
|
91 |
+
# Dataset info
|
92 |
+
urls_per_split = {
|
93 |
+
"train": "https://huggingface.co/datasets/mstz/uscensus/resolve/main/uscensus.csv"
|
94 |
+
}
|
95 |
+
features_types_per_config = {
|
96 |
+
"uscensus": {
|
97 |
+
"dAge": datasets.Value("integer"),
|
98 |
+
"dAncstry1": datasets.Value("integer"),
|
99 |
+
"dAncstry2": datasets.Value("integer"),
|
100 |
+
"iAvail": datasets.Value("integer"),
|
101 |
+
"iCitizen": datasets.Value("integer"),
|
102 |
+
"iClass": datasets.Value("integer"),
|
103 |
+
"dDepart": datasets.Value("integer"),
|
104 |
+
"iDisabl1": datasets.Value("integer"),
|
105 |
+
"iDisabl2": datasets.Value("integer"),
|
106 |
+
"iEnglish": datasets.Value("integer"),
|
107 |
+
"iFeb55": datasets.Value("integer"),
|
108 |
+
"iFertil": datasets.Value("integer"),
|
109 |
+
"dHispanic": datasets.Value("integer"),
|
110 |
+
"dHour89": datasets.Value("integer"),
|
111 |
+
"dHours": datasets.Value("integer"),
|
112 |
+
"iImmigr": datasets.Value("integer"),
|
113 |
+
"dIncome1": datasets.Value("integer"),
|
114 |
+
"dIncome2": datasets.Value("integer"),
|
115 |
+
"dIncome3": datasets.Value("integer"),
|
116 |
+
"dIncome4": datasets.Value("integer"),
|
117 |
+
"dIncome5": datasets.Value("integer"),
|
118 |
+
"dIncome6": datasets.Value("integer"),
|
119 |
+
"dIncome7": datasets.Value("integer"),
|
120 |
+
"dIncome8": datasets.Value("integer"),
|
121 |
+
"dIndustry": datasets.Value("integer"),
|
122 |
+
"iKorean": datasets.Value("integer"),
|
123 |
+
"iLang1": datasets.Value("integer"),
|
124 |
+
"iLooking": datasets.Value("integer"),
|
125 |
+
"iMarital": datasets.Value("integer"),
|
126 |
+
"iMay75880": datasets.Value("integer"),
|
127 |
+
"iMeans": datasets.Value("integer"),
|
128 |
+
"iMilitary": datasets.Value("integer"),
|
129 |
+
"iMobility": datasets.Value("integer"),
|
130 |
+
"iMobillim": datasets.Value("integer"),
|
131 |
+
"dOccup": datasets.Value("integer"),
|
132 |
+
"iOthrserv": datasets.Value("integer"),
|
133 |
+
"iPerscare": datasets.Value("integer"),
|
134 |
+
"dPOB": datasets.Value("integer"),
|
135 |
+
"dPoverty": datasets.Value("integer"),
|
136 |
+
"dPwgt1": datasets.Value("integer"),
|
137 |
+
"iRagechld": datasets.Value("integer"),
|
138 |
+
"dRearning": datasets.Value("integer"),
|
139 |
+
"iRelat1": datasets.Value("integer"),
|
140 |
+
"iRelat2": datasets.Value("integer"),
|
141 |
+
"iRemplpar": datasets.Value("integer"),
|
142 |
+
"iRiders": datasets.Value("integer"),
|
143 |
+
"iRlabor": datasets.Value("integer"),
|
144 |
+
"iRownchld": datasets.Value("integer"),
|
145 |
+
"dRpincome": datasets.Value("integer"),
|
146 |
+
"iRPOB": datasets.Value("integer"),
|
147 |
+
"iRrelchld": datasets.Value("integer"),
|
148 |
+
"iRspouse": datasets.Value("integer"),
|
149 |
+
"iRvetserv": datasets.Value("integer"),
|
150 |
+
"iSchool": datasets.Value("integer"),
|
151 |
+
"iSept80": datasets.Value("integer"),
|
152 |
+
"iSex": datasets.Value("integer"),
|
153 |
+
"iSubfam1": datasets.Value("integer"),
|
154 |
+
"iSubfam2": datasets.Value("integer"),
|
155 |
+
"iTmpabsnt": datasets.Value("integer"),
|
156 |
+
"dTravtime": datasets.Value("integer"),
|
157 |
+
"iVietnam": datasets.Value("integer"),
|
158 |
+
"dWeek89": datasets.Value("integer"),
|
159 |
+
"iWork89": datasets.Value("integer"),
|
160 |
+
"iWorklwk": datasets.Value("integer"),
|
161 |
+
"iWWII": datasets.Value("integer"),
|
162 |
+
"iYearsch": datasets.Value("integer"),
|
163 |
+
"iYearwrk": datasets.Value("integer"),
|
164 |
+
"dYrsserv": datasets.ClassLabel(num_classes=3)
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
169 |
+
|
170 |
+
|
171 |
+
class UscensusConfig(datasets.BuilderConfig):
|
172 |
+
def __init__(self, **kwargs):
|
173 |
+
super(UscensusConfig, self).__init__(version=VERSION, **kwargs)
|
174 |
+
self.features = features_per_config[kwargs["name"]]
|
175 |
+
|
176 |
+
|
177 |
+
class Uscensus(datasets.GeneratorBasedBuilder):
|
178 |
+
# dataset versions
|
179 |
+
DEFAULT_CONFIG = "uscensus"
|
180 |
+
BUILDER_CONFIGS = [UscensusConfig(name="uscensus", description="Uscensus for binary classification.")]
|
181 |
+
|
182 |
+
|
183 |
+
def _info(self):
|
184 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
185 |
+
features=features_per_config[self.config.name])
|
186 |
+
|
187 |
+
return info
|
188 |
+
|
189 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
190 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
191 |
+
|
192 |
+
return [
|
193 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
194 |
+
]
|
195 |
+
|
196 |
+
def _generate_examples(self, filepath: str):
|
197 |
+
data = pandas.read_csv(filepath, header=None)
|
198 |
+
data = self.preprocess(data)
|
199 |
+
|
200 |
+
for row_id, row in data.iterrows():
|
201 |
+
data_row = dict(row)
|
202 |
+
|
203 |
+
yield row_id, data_row
|
204 |
+
|
205 |
+
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
206 |
+
data.columns = _BASE_FEATURE_NAMES
|
207 |
+
|
208 |
+
for feature in _ENCODING_DICS:
|
209 |
+
encoding_function = partial(self.encode, feature)
|
210 |
+
data[feature] = data[feature].apply(encoding_function)
|
211 |
+
|
212 |
+
return data[list(features_types_per_config[self.config.name].keys())]
|
213 |
+
|
214 |
+
def encode(self, feature, value):
|
215 |
+
if feature in _ENCODING_DICS:
|
216 |
+
return _ENCODING_DICS[feature][value]
|
217 |
+
raise ValueError(f"Unknown feature: {feature}")
|
uscensus1990.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ab706d4d20053f6b15c679a4d56e6836c941f089c1ff4ee67a0c496619d7985b
|
3 |
+
size 361343635
|