mstz commited on
Commit
097b5e7
1 Parent(s): c87b6d0

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +19 -1
  3. dexter.data +3 -0
  4. dexter.py +90 -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
+ dexter.data filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,21 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - dexter
6
+ - tabular_classification
7
+ - binary_classification
8
+ - UCI
9
+ pretty_name: Dexter
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
+ - dexter
14
  ---
15
+ # Dexter
16
+ The [Dexter dataset](https://archive-beta.ics.uci.edu/dataset/109/wine) from the [UCI repository](https://archive-beta.ics.uci.edu/).
17
+
18
+ # Configurations and tasks
19
+ | **Configuration** | **Task** |
20
+ |-----------------------|---------------------------|
21
+ | dexter | Binary classification.|
dexter.data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:659cbcf953a1e469b65eefc5f1ac14ee5f52070399b8d85bdb2b516831955dcf
3
+ size 104343509
dexter.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Dexter 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 = "Dexter dataset."
21
+ _HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/127/dexter+census+database"
22
+ _URLS = ("https://archive-beta.ics.uci.edu/dataset/127/dexter+census+database")
23
+ _CITATION = """
24
+ @misc{misc_dexter_168,
25
+ author = {Guyon,Isabelle, Gunn,Steve, Ben-Hur,Asa & Dror,Gideon},
26
+ title = {{Dexter}},
27
+ year = {2008},
28
+ howpublished = {UCI Machine Learning Repository},
29
+ note = {{DOI}: \\url{10.24432/C5P898}}
30
+ }
31
+ """
32
+
33
+ # Dataset info
34
+ urls_per_split = {
35
+ "train": "https://huggingface.co/datasets/mstz/dexter/resolve/main/dexter.data"
36
+ }
37
+ features_types_per_config = {
38
+ "dexter": {f"feature_{i}": datasets.Value("float64") for i in range(20000)}
39
+ }
40
+ features_types_per_config["dexter"]["class"] = datasets.ClassLabel(num_classes=2)
41
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
42
+
43
+
44
+ class DexterConfig(datasets.BuilderConfig):
45
+ def __init__(self, **kwargs):
46
+ super(DexterConfig, self).__init__(version=VERSION, **kwargs)
47
+ self.features = features_per_config[kwargs["name"]]
48
+
49
+
50
+ class Dexter(datasets.GeneratorBasedBuilder):
51
+ # dataset versions
52
+ DEFAULT_CONFIG = "dexter"
53
+ BUILDER_CONFIGS = [DexterConfig(name="dexter", description="Dexter for binary classification.")]
54
+
55
+
56
+ def _info(self):
57
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
58
+ features=features_per_config[self.config.name])
59
+
60
+ return info
61
+
62
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
63
+ downloads = dl_manager.download_and_extract(urls_per_split)
64
+
65
+ return [
66
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
67
+ ]
68
+
69
+ def _generate_examples(self, filepath: str):
70
+ data = pandas.read_csv(filepath)
71
+ data = self.preprocess(data)
72
+
73
+ for row_id, row in data.iterrows():
74
+ data_row = dict(row)
75
+
76
+ yield row_id, data_row
77
+
78
+ def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
79
+ data.columns = [f"feature_{i}" for i in range(20000)] + ["class"]
80
+
81
+ for feature in _ENCODING_DICS:
82
+ encoding_function = partial(self.encode, feature)
83
+ data.loc[:, feature] = data[feature].apply(encoding_function)
84
+
85
+ return data[list(features_types_per_config[self.config.name].keys())]
86
+
87
+ def encode(self, feature, value):
88
+ if feature in _ENCODING_DICS:
89
+ return _ENCODING_DICS[feature][value]
90
+ raise ValueError(f"Unknown feature: {feature}")