mstz commited on
Commit
6668a7d
1 Parent(s): a47638e

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +16 -0
  3. sydt.csv +3 -0
  4. sydt.py +102 -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
+ sydt.csv filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - sydt
6
+ - tabular_classification
7
+ - binary_classification
8
+ - synthetic
9
+ pretty_name: Sydt
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
+ - sydt
14
+ ---
15
+ # Sydt
16
+ Synthetic dataset.
sydt.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82b79cfcfaaabb164e53d2c5d9291cadaee837b2f218311bdd368e12baeb9351
3
+ size 369620598
sydt.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Sydt 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
+ "salary",
16
+ "commission",
17
+ "age",
18
+ "education",
19
+ "car",
20
+ "zip",
21
+ "housevalue",
22
+ "yearsowned",
23
+ "loan",
24
+ "class",
25
+ ]
26
+
27
+ DESCRIPTION = "Sydt dataset."
28
+ _HOMEPAGE = ""
29
+ _URLS = ("")
30
+ _CITATION = """"""
31
+
32
+ # Dataset info
33
+ urls_per_split = {
34
+ "train": "https://huggingface.co/datasets/mstz/sydt/resolve/main/sydt.csv"
35
+ }
36
+ features_types_per_config = {
37
+ "sydt": {
38
+ "salary": datasets.Value("int64"),
39
+ "commission": datasets.Value("int64"),
40
+ "age": datasets.Value("int64"),
41
+ "education": datasets.Value("int64"),
42
+ "car": datasets.Value("int64"),
43
+ "zip": datasets.Value("string"),
44
+ "housevalue": datasets.Value("int64"),
45
+ "yearsowned": datasets.Value("int64"),
46
+ "loan": datasets.Value("int64"),
47
+ "class": datasets.ClassLabel(num_classes=2),
48
+ }
49
+ }
50
+
51
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
52
+
53
+
54
+ class SydtConfig(datasets.BuilderConfig):
55
+ def __init__(self, **kwargs):
56
+ super(SydtConfig, self).__init__(version=VERSION, **kwargs)
57
+ self.features = features_per_config[kwargs["name"]]
58
+
59
+
60
+ class Sydt(datasets.GeneratorBasedBuilder):
61
+ # dataset versions
62
+ DEFAULT_CONFIG = "sydt"
63
+ BUILDER_CONFIGS = [SydtConfig(name="sydt", description="Sydt for binary classification.")]
64
+
65
+
66
+ def _info(self):
67
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
68
+ features=features_per_config[self.config.name])
69
+
70
+ return info
71
+
72
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
73
+ downloads = dl_manager.download_and_extract(urls_per_split)
74
+
75
+ return [
76
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
77
+ ]
78
+
79
+ def _generate_examples(self, filepath: str):
80
+ data = pandas.read_csv(filepath, header=None)
81
+ data = self.preprocess(data)
82
+
83
+ for row_id, row in data.iterrows():
84
+ data_row = dict(row)
85
+
86
+ yield row_id, data_row
87
+
88
+ def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
89
+ data.columns = _BASE_FEATURE_NAMES
90
+ data = data[~data["class"].isna()]
91
+ data["class"] = data["class"].apply(lambda x: x - 1)
92
+
93
+ for feature in _ENCODING_DICS:
94
+ encoding_function = partial(self.encode, feature)
95
+ data[feature] = data[feature].apply(encoding_function)
96
+
97
+ return data[list(features_types_per_config[self.config.name].keys())]
98
+
99
+ def encode(self, feature, value):
100
+ if feature in _ENCODING_DICS:
101
+ return _ENCODING_DICS[feature][value]
102
+ raise ValueError(f"Unknown feature: {feature}")