Datasets:
Upload 3 files
Browse files
README.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- golf
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
pretty_name: Golf
|
9 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
10 |
+
- tabular-classification
|
11 |
+
configs:
|
12 |
+
- golf
|
13 |
---
|
14 |
+
# Golf
|
15 |
+
The Golf dataset.
|
16 |
+
Is it a good day to play golf?
|
17 |
+
|
18 |
+
# Configurations and tasks
|
19 |
+
| **Configuration** | **Task** |
|
20 |
+
|-----------------------|---------------------------|
|
21 |
+
| golf | Binary classification.|
|
golf.data
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
outlook,temperature,humidity,windy,goodPlaying,toPlay
|
2 |
+
sunny,85,85,false,1,Don't Play
|
3 |
+
sunny,80,90,true,1,Don't Play
|
4 |
+
overcast,83,78,false,1.5,Play
|
5 |
+
rain,70,96,false,0.8,Play
|
6 |
+
rain,68,80,false,2,Play
|
7 |
+
rain,65,70,true,1,Don't Play
|
8 |
+
overcast,64,65,true,2.5,Play
|
9 |
+
sunny,72,95,false,1,Don't Play
|
10 |
+
sunny,69,70,false,1,Play
|
11 |
+
rain,75,80,false,1.5,Play
|
12 |
+
sunny,75,70,true,3,Play
|
13 |
+
overcast,72,90,true,1.5,Play
|
14 |
+
overcast,81,75,false,1,Play
|
15 |
+
rain,71,80,true,1,Don't Play
|
golf.py
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Golf 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 |
+
"toPlay": {
|
15 |
+
"Don't Play": 0,
|
16 |
+
"Play": 1
|
17 |
+
},
|
18 |
+
"windy": {
|
19 |
+
"false": False,
|
20 |
+
"true": True
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
DESCRIPTION = "Golf dataset."
|
25 |
+
_HOMEPAGE = ""
|
26 |
+
_URLS = ("")
|
27 |
+
_CITATION = """"""
|
28 |
+
|
29 |
+
# Dataset info
|
30 |
+
urls_per_split = {
|
31 |
+
"train": "https://huggingface.co/datasets/mstz/golf/resolve/main/golf.data"
|
32 |
+
}
|
33 |
+
features_types_per_config = {
|
34 |
+
"golf": {
|
35 |
+
"outlook": datasets.Value("string"),
|
36 |
+
"temperature": datasets.Value("int8"),
|
37 |
+
"humidity": datasets.Value("int8"),
|
38 |
+
"windy": datasets.Value("bool"),
|
39 |
+
"goodPlaying": datasets.Value("float64"),
|
40 |
+
"toPlay": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
41 |
+
}
|
42 |
+
}
|
43 |
+
features_types_per_config["golf"]["class"] = datasets.ClassLabel(num_classes=2)
|
44 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
45 |
+
|
46 |
+
|
47 |
+
class GolfConfig(datasets.BuilderConfig):
|
48 |
+
def __init__(self, **kwargs):
|
49 |
+
super(GolfConfig, self).__init__(version=VERSION, **kwargs)
|
50 |
+
self.features = features_per_config[kwargs["name"]]
|
51 |
+
|
52 |
+
|
53 |
+
class Golf(datasets.GeneratorBasedBuilder):
|
54 |
+
# dataset versions
|
55 |
+
DEFAULT_CONFIG = "golf"
|
56 |
+
BUILDER_CONFIGS = [
|
57 |
+
GolfConfig(name="golf", description="Golf for binary classification.")
|
58 |
+
]
|
59 |
+
|
60 |
+
|
61 |
+
def _info(self):
|
62 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
63 |
+
features=features_per_config[self.config.name])
|
64 |
+
|
65 |
+
return info
|
66 |
+
|
67 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
68 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
69 |
+
|
70 |
+
return [
|
71 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
72 |
+
]
|
73 |
+
|
74 |
+
def _generate_examples(self, filepath: str):
|
75 |
+
data = pandas.read_csv(filepath, header=None)
|
76 |
+
data = self.preprocess(data)
|
77 |
+
|
78 |
+
for row_id, row in data.iterrows():
|
79 |
+
data_row = dict(row)
|
80 |
+
|
81 |
+
yield row_id, data_row
|
82 |
+
|
83 |
+
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
84 |
+
for feature in _ENCODING_DICS:
|
85 |
+
encoding_function = partial(self.encode, feature)
|
86 |
+
data.loc[:, feature] = data[feature].apply(encoding_function)
|
87 |
+
|
88 |
+
return data[list(features_types_per_config[self.config.name].keys())]
|
89 |
+
|
90 |
+
def encode(self, feature, value):
|
91 |
+
if feature in _ENCODING_DICS:
|
92 |
+
return _ENCODING_DICS[feature][value]
|
93 |
+
raise ValueError(f"Unknown feature: {feature}")
|