Datasets:
Upload 3 files
Browse files
.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 |
+
pums.csv filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- pums
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
- UCI
|
9 |
+
pretty_name: Ipums
|
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 |
+
- pums
|
14 |
---
|
15 |
+
# Pums
|
16 |
+
The [Pums dataset](https://archive-beta.ics.uci.edu/dataset/116/us+census+data+1990) from the [UCI repository](https://archive-beta.ics.uci.edu/).
|
17 |
+
U.S.A. Census dataset, classify the income of the individual.
|
18 |
+
|
19 |
+
|
20 |
+
# Configurations and tasks
|
21 |
+
| **Configuration** | **Task** |
|
22 |
+
|-----------------------|---------------------------|
|
23 |
+
| pums | Binary classification.|
|
pums.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6905c75708458f5a1a8809e19a5e3aae21549f964edbe06ebc6b1dab3e6aac6d
|
3 |
+
size 141527293
|
pums.py
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Pums 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 |
+
"class": {
|
15 |
+
"- 50000.": 0,
|
16 |
+
"50000+.": 1
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
DESCRIPTION = "Pums dataset."
|
21 |
+
_HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/116/us+census+data+1990"
|
22 |
+
_URLS = ("https://archive-beta.ics.uci.edu/dataset/116/us+census+data+1990")
|
23 |
+
_CITATION = """
|
24 |
+
@misc{misc_us_census_data_(1990)_116,
|
25 |
+
author = {Meek,Meek, Thiesson,Thiesson & Heckerman,Heckerman},
|
26 |
+
title = {{US Census Data (1990)}},
|
27 |
+
howpublished = {UCI Machine Learning Repository},
|
28 |
+
note = {{DOI}: \\url{10.24432/C5VP42}}
|
29 |
+
}
|
30 |
+
"""
|
31 |
+
|
32 |
+
# Dataset info
|
33 |
+
urls_per_split = {
|
34 |
+
"train": "https://huggingface.co/datasets/mstz/pums/resolve/main/pums.csv"
|
35 |
+
}
|
36 |
+
features_types_per_config = {
|
37 |
+
"pums": {
|
38 |
+
"age": datasets.Value("int64"),
|
39 |
+
"class_of_worker": datasets.Value("string"),
|
40 |
+
"detailed_industry_recode": datasets.Value("string"),
|
41 |
+
"detailed_occupation_recode": datasets.Value("string"),
|
42 |
+
"education": datasets.Value("string"),
|
43 |
+
"wage_per_hour": datasets.Value("int64"),
|
44 |
+
"enroll_in_edu_inst_last_wk": datasets.Value("string"),
|
45 |
+
"marital_stat": datasets.Value("string"),
|
46 |
+
"major_industry_code": datasets.Value("string"),
|
47 |
+
"major_occupation_code": datasets.Value("string"),
|
48 |
+
"race": datasets.Value("string"),
|
49 |
+
"hispanic_origin": datasets.Value("string"),
|
50 |
+
"sex": datasets.Value("string"),
|
51 |
+
"member_of_a_labor_union": datasets.Value("string"),
|
52 |
+
"reason_for_unemployment": datasets.Value("string"),
|
53 |
+
"full_or_part_time_employment_stat": datasets.Value("string"),
|
54 |
+
"capital_gains": datasets.Value("int64"),
|
55 |
+
"capital_losses": datasets.Value("int64"),
|
56 |
+
"dividends_from_stocks": datasets.Value("int64"),
|
57 |
+
"tax_filer_stat": datasets.Value("string"),
|
58 |
+
"region_of_previous_residence": datasets.Value("string"),
|
59 |
+
"state_of_previous_residence": datasets.Value("string"),
|
60 |
+
"detailed_household_and_family_stat": datasets.Value("string"),
|
61 |
+
"detailed_household_summary_in_household": datasets.Value("string"),
|
62 |
+
# "instance_weight": datasets.Value("int64"),
|
63 |
+
"migration_code_change_in_msa": datasets.Value("string"),
|
64 |
+
"migration_code_change_in_reg": datasets.Value("string"),
|
65 |
+
"migration_code_move_within_reg": datasets.Value("string"),
|
66 |
+
"live_in_this_house_1_year_ago": datasets.Value("string"),
|
67 |
+
"migration_prev_res_in_sunbelt": datasets.Value("string"),
|
68 |
+
"num_persons_worked_for_employer": datasets.Value("int64"),
|
69 |
+
"family_members_under_18": datasets.Value("string"),
|
70 |
+
"country_of_birth_father": datasets.Value("string"),
|
71 |
+
"country_of_birth_mother": datasets.Value("string"),
|
72 |
+
"country_of_birth_self": datasets.Value("string"),
|
73 |
+
"citizenship": datasets.Value("string"),
|
74 |
+
"own_business_or_self_employed": datasets.Value("string"),
|
75 |
+
"fill_inc_questionnaire_for_veteran_admin": datasets.Value("string"),
|
76 |
+
"veterans_benefits": datasets.Value("string"),
|
77 |
+
"weeks_worked_in_year": datasets.Value("int64"),
|
78 |
+
"year": datasets.Value("int64"),
|
79 |
+
"class": datasets.ClassLabel(num_classes=2)
|
80 |
+
}
|
81 |
+
}
|
82 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
83 |
+
|
84 |
+
|
85 |
+
class PumsConfig(datasets.BuilderConfig):
|
86 |
+
def __init__(self, **kwargs):
|
87 |
+
super(PumsConfig, self).__init__(version=VERSION, **kwargs)
|
88 |
+
self.features = features_per_config[kwargs["name"]]
|
89 |
+
|
90 |
+
|
91 |
+
class Pums(datasets.GeneratorBasedBuilder):
|
92 |
+
# dataset versions
|
93 |
+
DEFAULT_CONFIG = "pums"
|
94 |
+
BUILDER_CONFIGS = [PumsConfig(name="pums", description="Pums for binary classification.")]
|
95 |
+
|
96 |
+
|
97 |
+
def _info(self):
|
98 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
99 |
+
features=features_per_config[self.config.name])
|
100 |
+
|
101 |
+
return info
|
102 |
+
|
103 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
104 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
105 |
+
|
106 |
+
return [
|
107 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
108 |
+
]
|
109 |
+
|
110 |
+
def _generate_examples(self, filepath: str):
|
111 |
+
data = pandas.read_csv(filepath)
|
112 |
+
data = self.preprocess(data)
|
113 |
+
|
114 |
+
for row_id, row in data.iterrows():
|
115 |
+
data_row = dict(row)
|
116 |
+
|
117 |
+
yield row_id, data_row
|
118 |
+
|
119 |
+
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
120 |
+
for feature in _ENCODING_DICS:
|
121 |
+
encoding_function = partial(self.encode, feature)
|
122 |
+
data.loc[:, feature] = data[feature].apply(encoding_function)
|
123 |
+
|
124 |
+
data.drop("instance_weight", axis="columns", inplace=True)
|
125 |
+
data = data.rename(columns={"instance migration_code_change_in_msa": "migration_code_change_in_msa"})
|
126 |
+
|
127 |
+
return data[list(features_types_per_config[self.config.name].keys())]
|
128 |
+
|
129 |
+
def encode(self, feature, value):
|
130 |
+
if feature in _ENCODING_DICS:
|
131 |
+
return _ENCODING_DICS[feature][value]
|
132 |
+
raise ValueError(f"Unknown feature: {feature}")
|