mstz commited on
Commit
8fb9459
1 Parent(s): 0a787d6

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +28 -1
  2. electricity-normalized.csv +0 -0
  3. electricity.py +71 -0
README.md CHANGED
@@ -1,3 +1,30 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - electricity
6
+ - tabular_classification
7
+ - binary_classification
8
+ pretty_name: Electricity
9
+ size_categories:
10
+ - 10k<n<100K
11
+ task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
12
+ - tabular-classification
13
+ configs:
14
+ - electricity
15
  ---
16
+ # Electricity
17
+ The [Electricity dataset](https://www.openml.org/search?type=data&sort=runs&id=151&status=active) from the [OpenML repository](https://www.openml.org/).
18
+
19
+ # Configurations and tasks
20
+ | **Configuration** | **Task** | **Description** |
21
+ |-------------------|---------------------------|-------------------------|
22
+ | electricity | Binary classification | Has the electricity cost gone up?|
23
+
24
+
25
+ # Usage
26
+ ```python
27
+ from datasets import load_dataset
28
+
29
+ dataset = load_dataset("mstz/electricity", "electricity")["train"]
30
+ ```
electricity-normalized.csv ADDED
The diff for this file is too large to render. See raw diff
 
electricity.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = "Electricity dataset from the UCI ML repository."
12
+ _HOMEPAGE = "ttps://www.openml.org/search?type=data&sort=runs&id=151&status=active"
13
+ _URLS = ("ttps://www.openml.org/search?type=data&sort=runs&id=151&status=active")
14
+ _CITATION = """"""
15
+
16
+ # Dataset info
17
+ urls_per_split = {
18
+ "train": "https://huggingface.co/datasets/mstz/electricity/raw/main/electricity-normalized.csv"
19
+ }
20
+ features_types_per_config = {
21
+ "electricity": {
22
+ "date": datasets.Value("float64"),
23
+ "day": datasets.Value("int8"),
24
+ "period": datasets.Value("float64"),
25
+ "nswprice": datasets.Value("float64"),
26
+ "nswdemand": datasets.Value("float64"),
27
+ "vicprice": datasets.Value("float64"),
28
+ "vicdemand": datasets.Value("float64"),
29
+ "transfer": datasets.Value("float64"),
30
+ "is_up": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
31
+ }
32
+
33
+ }
34
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
35
+
36
+
37
+ class ElectricityConfig(datasets.BuilderConfig):
38
+ def __init__(self, **kwargs):
39
+ super(ElectricityConfig, self).__init__(version=VERSION, **kwargs)
40
+ self.features = features_per_config[kwargs["name"]]
41
+
42
+
43
+ class Electricity(datasets.GeneratorBasedBuilder):
44
+ # dataset versions
45
+ DEFAULT_CONFIG = "electricity"
46
+ BUILDER_CONFIGS = [
47
+ ElectricityConfig(name="electricity",
48
+ description="Electricity for binary classification.")
49
+ ]
50
+
51
+
52
+ def _info(self):
53
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
54
+ features=features_per_config[self.config.name])
55
+
56
+ return info
57
+
58
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
59
+ downloads = dl_manager.download_and_extract(urls_per_split)
60
+
61
+ return [
62
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
63
+ ]
64
+
65
+ def _generate_examples(self, filepath: str):
66
+ data = pandas.read_csv(filepath)
67
+
68
+ for row_id, row in data.iterrows():
69
+ data_row = dict(row)
70
+
71
+ yield row_id, data_row