mstz commited on
Commit
95fb2a6
1 Parent(s): 65427d0

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +19 -0
  2. madelon.py +74 -0
  3. madelon_train.csv +0 -0
  4. madelon_valid.csv +0 -0
README.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - madelon
6
+ - tabular_classification
7
+ pretty_name: Annealing
8
+ size_categories:
9
+ - 1K<n<10K
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
+ - Madelon
14
+ ---
15
+ # Annealing
16
+ The [Madelon dataset](https://archive-beta.ics.uci.edu/dataset/171/madelon) from the [UCI ML repository](https://archive.ics.uci.edu/ml/datasets).
17
+
18
+ # Configurations and tasks
19
+ - `madelon` for binary classification.
madelon.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List
2
+
3
+ import datasets
4
+
5
+ import pandas
6
+
7
+
8
+ VERSION = datasets.Version("1.0.0")
9
+
10
+
11
+ DESCRIPTION = "Madelon dataset from the UCI ML repository."
12
+ _HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/3/madelon"
13
+ _URLS = ("https://archive-beta.ics.uci.edu/dataset/3/madelon")
14
+ _CITATION = """"""
15
+
16
+ # Dataset info
17
+ urls_per_split = {
18
+ "train": "https://huggingface.co/datasets/mstz/madelon/raw/main/madelon_train.csv",
19
+ "validation": "https://huggingface.co/datasets/mstz/madelon/raw/main/madelon_valid.csv"
20
+ }
21
+ features_types_per_config = {
22
+ "madelon": {str(i): datasets.Value("float32") for i in range(500)}
23
+ }
24
+
25
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
26
+
27
+
28
+ class MadelonConfig(datasets.BuilderConfig):
29
+ def __init__(self, **kwargs):
30
+ super(MadelonConfig, self).__init__(version=VERSION, **kwargs)
31
+ self.features = features_per_config[kwargs["name"]]
32
+
33
+
34
+ class Madelon(datasets.GeneratorBasedBuilder):
35
+ # dataset versions
36
+ DEFAULT_CONFIG = "madelon"
37
+ BUILDER_CONFIGS = [
38
+ MadelonConfig(name="madelon",
39
+ description="Madelon for multiclass classification.")
40
+ ]
41
+
42
+
43
+ def _info(self):
44
+ if self.config.name not in features_per_config:
45
+ raise ValueError(f"Unknown configuration: {self.config.name}")
46
+
47
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
48
+ features=features_per_config[self.config.name])
49
+
50
+ return info
51
+
52
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
53
+ downloads = dl_manager.download_and_extract(urls_per_split)
54
+
55
+ return [
56
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
57
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"]})
58
+ ]
59
+
60
+ def _generate_examples(self, filepath: str):
61
+ data = pandas.read_csv(filepath)
62
+ data = self.preprocess(data, config=self.config.name)
63
+
64
+ for row_id, row in data.iterrows():
65
+ data_row = dict(row)
66
+
67
+ yield row_id, data_row
68
+
69
+ def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame:
70
+ features_types_per_config["madelon"].update({"500": datasets.ClassLabel(num_classes=2)})
71
+ data.columns = list(range(501))
72
+ data.loc[:, "500"] = data["500"].apply(lambda x: x if x > 0 else 0)
73
+
74
+ return data
madelon_train.csv ADDED
The diff for this file is too large to render. See raw diff
 
madelon_valid.csv ADDED
The diff for this file is too large to render. See raw diff