mstz commited on
Commit
69d3bfe
·
1 Parent(s): 9006e8f

Upload adult.py

Browse files
Files changed (1) hide show
  1. adult.py +10 -10
adult.py CHANGED
@@ -8,7 +8,7 @@ import pandas
8
 
9
 
10
  VERSION = datasets.Version("1.0.0")
11
- __ORIGINAL_FEATURE_NAMES = [
12
  "age",
13
  "workclass",
14
  "final_weight",
@@ -24,7 +24,7 @@ __ORIGINAL_FEATURE_NAMES = [
24
  "native_country",
25
  "threshold"
26
  ]
27
- __BASE_FEATURE_NAMES = [
28
  "age",
29
  "capital_gain",
30
  "capital_loss",
@@ -40,10 +40,10 @@ __BASE_FEATURE_NAMES = [
40
  "workclass",
41
  "threshold",
42
  ]
43
- __DESCRIPTION = "Adult dataset from the UCI ML repository."
44
- __HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Adult"
45
- __URLS = ("https://huggingface.co/datasets/mstz/adult/raw/adult.csv")
46
- __CITATION = """
47
  @inproceedings{DBLP:conf/kdd/Kohavi96,
48
  author = {Ron Kohavi},
49
  editor = {Evangelos Simoudis and
@@ -63,7 +63,7 @@ __CITATION = """
63
  }"""
64
 
65
  # Dataset info
66
- __urls_per_split = {
67
  "train": "https://huggingface.co/datasets/mstz/adult/raw/adult_tr.csv",
68
  "test": "https://huggingface.co/datasets/mstz/adult/raw/adult_ts.csv"
69
  }
@@ -142,13 +142,13 @@ class Adult(datasets.GeneratorBasedBuilder):
142
  if self.config.name not in features_per_config:
143
  raise ValueError(f"Unknown configuration: {self.config.name}")
144
 
145
- info = datasets.DatasetInfo(description=__DESCRIPTION, citation=__CITATION, homepage=__HOMEPAGE,
146
  features=features_per_config[self.config.name])
147
 
148
  return info
149
 
150
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
151
- downloads = dl_manager.download_and_extract(__urls_per_split)
152
 
153
  return [
154
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
@@ -170,7 +170,7 @@ class Adult(datasets.GeneratorBasedBuilder):
170
  data = data[["age", "capital_gain", "capital_loss", "education", "final_weight",
171
  "hours_per_week", "marital_status", "native_country", "occupation",
172
  "race", "relationship", "sex", "workclass", "threshold"]]
173
- data.columns = __BASE_FEATURE_NAMES
174
 
175
  return data
176
 
 
8
 
9
 
10
  VERSION = datasets.Version("1.0.0")
11
+ _ORIGINAL_FEATURE_NAMES = [
12
  "age",
13
  "workclass",
14
  "final_weight",
 
24
  "native_country",
25
  "threshold"
26
  ]
27
+ _BASE_FEATURE_NAMES = [
28
  "age",
29
  "capital_gain",
30
  "capital_loss",
 
40
  "workclass",
41
  "threshold",
42
  ]
43
+ DESCRIPTION = "Adult dataset from the UCI ML repository."
44
+ _HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Adult"
45
+ _URLS = ("https://huggingface.co/datasets/mstz/adult/raw/adult.csv")
46
+ _CITATION = """
47
  @inproceedings{DBLP:conf/kdd/Kohavi96,
48
  author = {Ron Kohavi},
49
  editor = {Evangelos Simoudis and
 
63
  }"""
64
 
65
  # Dataset info
66
+ _urls_per_split = {
67
  "train": "https://huggingface.co/datasets/mstz/adult/raw/adult_tr.csv",
68
  "test": "https://huggingface.co/datasets/mstz/adult/raw/adult_ts.csv"
69
  }
 
142
  if self.config.name not in features_per_config:
143
  raise ValueError(f"Unknown configuration: {self.config.name}")
144
 
145
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
146
  features=features_per_config[self.config.name])
147
 
148
  return info
149
 
150
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
151
+ downloads = dl_manager.download_and_extract(_urls_per_split)
152
 
153
  return [
154
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
 
170
  data = data[["age", "capital_gain", "capital_loss", "education", "final_weight",
171
  "hours_per_week", "marital_status", "native_country", "occupation",
172
  "race", "relationship", "sex", "workclass", "threshold"]]
173
+ data.columns = _BASE_FEATURE_NAMES
174
 
175
  return data
176