Datasets:
Upload 3 files
Browse files- README.md +29 -1
- shuttle.csv +0 -0
- shuttle.py +202 -0
README.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- shuttle
|
6 |
+
- tabular_classification
|
7 |
+
- binary_classification
|
8 |
+
- multiclass_classification
|
9 |
+
pretty_name: Shuttle
|
10 |
+
size_categories:
|
11 |
+
- 10K<n<100K
|
12 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
13 |
+
- tabular-classification
|
14 |
+
configs:
|
15 |
+
- shuttle
|
16 |
+
- shuttle_binary
|
17 |
---
|
18 |
+
# Shuttle
|
19 |
+
The [Shuttle dataset](https://archive-beta.ics.uci.edu/dataset/146/statlog+shuttle+satellite) from the [UCI repository](https://archive-beta.ics.uci.edu/).
|
20 |
+
|
21 |
+
# Configurations and tasks
|
22 |
+
| **Configuration** | **Task** | **Description** |
|
23 |
+
|-----------------------|---------------------------|-------------------------|
|
24 |
+
| shuttle | Multiclass classification.| |
|
25 |
+
| shuttle_0 | Binary classification. | Is the image of class 0? |
|
26 |
+
| shuttle_1 | Binary classification. | Is the image of class 1? |
|
27 |
+
| shuttle_2 | Binary classification. | Is the image of class 2? |
|
28 |
+
| shuttle_3 | Binary classification. | Is the image of class 3? |
|
29 |
+
| shuttle_4 | Binary classification. | Is the image of class 4? |
|
30 |
+
| shuttle_5 | Binary classification. | Is the image of class 5? |
|
31 |
+
| shuttle_6 | Binary classification. | Is the image of class 6? |
|
shuttle.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
shuttle.py
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Shuttle 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 |
+
|
15 |
+
DESCRIPTION = "Shuttle dataset."
|
16 |
+
_HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/148/statlog+shuttle"
|
17 |
+
_URLS = ("https://archive-beta.ics.uci.edu/dataset/148/statlog+shuttle")
|
18 |
+
_CITATION = """
|
19 |
+
@misc{misc_statlog_(shuttle)_148,
|
20 |
+
title = {{Statlog (Shuttle)}},
|
21 |
+
howpublished = {UCI Machine Learning Repository},
|
22 |
+
note = {{DOI}: \url{10.24432/C5WS31}}
|
23 |
+
}
|
24 |
+
"""
|
25 |
+
|
26 |
+
# Dataset info
|
27 |
+
urls_per_split = {
|
28 |
+
"train": "https://huggingface.co/datasets/mstz/shuttle/raw/main/shuttle.csv"
|
29 |
+
}
|
30 |
+
features_types_per_config = {
|
31 |
+
"shuttle": {
|
32 |
+
"time": datasets.Value("float64"),
|
33 |
+
"rad_flow": datasets.Value("float64"),
|
34 |
+
"fpv_close": datasets.Value("float64"),
|
35 |
+
"fpv_open": datasets.Value("float64"),
|
36 |
+
"high": datasets.Value("float64"),
|
37 |
+
"bypass": datasets.Value("float64"),
|
38 |
+
"bvp_close": datasets.Value("float64"),
|
39 |
+
"bvp_open": datasets.Value("float64"),
|
40 |
+
"feature": datasets.Value("float64"),
|
41 |
+
"class": datasets.ClassLabel(num_classes=7),
|
42 |
+
},
|
43 |
+
"shuttle_0": {
|
44 |
+
"time": datasets.Value("float64"),
|
45 |
+
"rad_flow": datasets.Value("float64"),
|
46 |
+
"fpv_close": datasets.Value("float64"),
|
47 |
+
"fpv_open": datasets.Value("float64"),
|
48 |
+
"high": datasets.Value("float64"),
|
49 |
+
"bypass": datasets.Value("float64"),
|
50 |
+
"bvp_close": datasets.Value("float64"),
|
51 |
+
"bvp_open": datasets.Value("float64"),
|
52 |
+
"feature": datasets.Value("float64"),
|
53 |
+
"class": datasets.ClassLabel(num_classes=2),
|
54 |
+
},
|
55 |
+
"shuttle_1": {
|
56 |
+
"time": datasets.Value("float64"),
|
57 |
+
"rad_flow": datasets.Value("float64"),
|
58 |
+
"fpv_close": datasets.Value("float64"),
|
59 |
+
"fpv_open": datasets.Value("float64"),
|
60 |
+
"high": datasets.Value("float64"),
|
61 |
+
"bypass": datasets.Value("float64"),
|
62 |
+
"bvp_close": datasets.Value("float64"),
|
63 |
+
"bvp_open": datasets.Value("float64"),
|
64 |
+
"feature": datasets.Value("float64"),
|
65 |
+
"class": datasets.ClassLabel(num_classes=2),
|
66 |
+
},
|
67 |
+
"shuttle_2": {
|
68 |
+
"time": datasets.Value("float64"),
|
69 |
+
"rad_flow": datasets.Value("float64"),
|
70 |
+
"fpv_close": datasets.Value("float64"),
|
71 |
+
"fpv_open": datasets.Value("float64"),
|
72 |
+
"high": datasets.Value("float64"),
|
73 |
+
"bypass": datasets.Value("float64"),
|
74 |
+
"bvp_close": datasets.Value("float64"),
|
75 |
+
"bvp_open": datasets.Value("float64"),
|
76 |
+
"feature": datasets.Value("float64"),
|
77 |
+
"class": datasets.ClassLabel(num_classes=2),
|
78 |
+
},
|
79 |
+
"shuttle_3": {
|
80 |
+
"time": datasets.Value("float64"),
|
81 |
+
"rad_flow": datasets.Value("float64"),
|
82 |
+
"fpv_close": datasets.Value("float64"),
|
83 |
+
"fpv_open": datasets.Value("float64"),
|
84 |
+
"high": datasets.Value("float64"),
|
85 |
+
"bypass": datasets.Value("float64"),
|
86 |
+
"bvp_close": datasets.Value("float64"),
|
87 |
+
"bvp_open": datasets.Value("float64"),
|
88 |
+
"feature": datasets.Value("float64"),
|
89 |
+
"class": datasets.ClassLabel(num_classes=2),
|
90 |
+
},
|
91 |
+
"shuttle_4": {
|
92 |
+
"time": datasets.Value("float64"),
|
93 |
+
"rad_flow": datasets.Value("float64"),
|
94 |
+
"fpv_close": datasets.Value("float64"),
|
95 |
+
"fpv_open": datasets.Value("float64"),
|
96 |
+
"high": datasets.Value("float64"),
|
97 |
+
"bypass": datasets.Value("float64"),
|
98 |
+
"bvp_close": datasets.Value("float64"),
|
99 |
+
"bvp_open": datasets.Value("float64"),
|
100 |
+
"feature": datasets.Value("float64"),
|
101 |
+
"class": datasets.ClassLabel(num_classes=2),
|
102 |
+
},
|
103 |
+
"shuttle_5": {
|
104 |
+
"time": datasets.Value("float64"),
|
105 |
+
"rad_flow": datasets.Value("float64"),
|
106 |
+
"fpv_close": datasets.Value("float64"),
|
107 |
+
"fpv_open": datasets.Value("float64"),
|
108 |
+
"high": datasets.Value("float64"),
|
109 |
+
"bypass": datasets.Value("float64"),
|
110 |
+
"bvp_close": datasets.Value("float64"),
|
111 |
+
"bvp_open": datasets.Value("float64"),
|
112 |
+
"feature": datasets.Value("float64"),
|
113 |
+
"class": datasets.ClassLabel(num_classes=2),
|
114 |
+
},
|
115 |
+
"shuttle_6": {
|
116 |
+
"time": datasets.Value("float64"),
|
117 |
+
"rad_flow": datasets.Value("float64"),
|
118 |
+
"fpv_close": datasets.Value("float64"),
|
119 |
+
"fpv_open": datasets.Value("float64"),
|
120 |
+
"high": datasets.Value("float64"),
|
121 |
+
"bypass": datasets.Value("float64"),
|
122 |
+
"bvp_close": datasets.Value("float64"),
|
123 |
+
"bvp_open": datasets.Value("float64"),
|
124 |
+
"feature": datasets.Value("float64"),
|
125 |
+
"class": datasets.ClassLabel(num_classes=2),
|
126 |
+
},
|
127 |
+
}
|
128 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
129 |
+
|
130 |
+
|
131 |
+
class ShuttleConfig(datasets.BuilderConfig):
|
132 |
+
def __init__(self, **kwargs):
|
133 |
+
super(ShuttleConfig, self).__init__(version=VERSION, **kwargs)
|
134 |
+
self.features = features_per_config[kwargs["name"]]
|
135 |
+
|
136 |
+
|
137 |
+
class Shuttle(datasets.GeneratorBasedBuilder):
|
138 |
+
# dataset versions
|
139 |
+
DEFAULT_CONFIG = "shuttle"
|
140 |
+
BUILDER_CONFIGS = [
|
141 |
+
ShuttleConfig(name="shuttle", description="Shuttle for multiclass classification."),
|
142 |
+
ShuttleConfig(name="shuttle_0", description="Shuttle for binary classification."),
|
143 |
+
ShuttleConfig(name="shuttle_1", description="Shuttle for binary classification."),
|
144 |
+
ShuttleConfig(name="shuttle_2", description="Shuttle for binary classification."),
|
145 |
+
ShuttleConfig(name="shuttle_3", description="Shuttle for binary classification."),
|
146 |
+
ShuttleConfig(name="shuttle_4", description="Shuttle for binary classification."),
|
147 |
+
ShuttleConfig(name="shuttle_5", description="Shuttle for binary classification."),
|
148 |
+
ShuttleConfig(name="shuttle_6", description="Shuttle for binary classification."),
|
149 |
+
|
150 |
+
]
|
151 |
+
|
152 |
+
|
153 |
+
def _info(self):
|
154 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
155 |
+
features=features_per_config[self.config.name])
|
156 |
+
|
157 |
+
return info
|
158 |
+
|
159 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
160 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
161 |
+
|
162 |
+
return [
|
163 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
164 |
+
]
|
165 |
+
|
166 |
+
def _generate_examples(self, filepath: str):
|
167 |
+
data = pandas.read_csv(filepath)
|
168 |
+
data = self.preprocess(data)
|
169 |
+
|
170 |
+
for row_id, row in data.iterrows():
|
171 |
+
data_row = dict(row)
|
172 |
+
|
173 |
+
yield row_id, data_row
|
174 |
+
|
175 |
+
def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
|
176 |
+
data["class"] = data["class"].apply(lambda x: x - 1)
|
177 |
+
|
178 |
+
if self.config.name == "shuttle_0":
|
179 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 0 else 0)
|
180 |
+
elif self.config.name == "shuttle_1":
|
181 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 1 else 0)
|
182 |
+
elif self.config.name == "shuttle_2":
|
183 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 2 else 0)
|
184 |
+
elif self.config.name == "shuttle_3":
|
185 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 3 else 0)
|
186 |
+
elif self.config.name == "shuttle_4":
|
187 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 4 else 0)
|
188 |
+
elif self.config.name == "shuttle_5":
|
189 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 5 else 0)
|
190 |
+
elif self.config.name == "shuttle_6":
|
191 |
+
data["class"] = data["class"].apply(lambda x: 1 if x == 6 else 0)
|
192 |
+
|
193 |
+
for feature in _ENCODING_DICS:
|
194 |
+
encoding_function = partial(self.encode, feature)
|
195 |
+
data.loc[:, feature] = data[feature].apply(encoding_function)
|
196 |
+
|
197 |
+
return data[list(features_types_per_config[self.config.name].keys())]
|
198 |
+
|
199 |
+
def encode(self, feature, value):
|
200 |
+
if feature in _ENCODING_DICS:
|
201 |
+
return _ENCODING_DICS[feature][value]
|
202 |
+
raise ValueError(f"Unknown feature: {feature}")
|