mstz commited on
Commit
f0cedcd
1 Parent(s): 223439e

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +25 -1
  2. splice.data +0 -0
  3. splice.py +357 -0
README.md CHANGED
@@ -1,3 +1,27 @@
1
  ---
2
- license: cc-by-4.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - splice
6
+ - tabular_classification
7
+ pretty_name: Splice
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
+ - splice
14
+ - splice_EI
15
+ - splice_IE
16
+ - splice_N
17
  ---
18
+ # Splice
19
+ The [Splice dataset](https://archive-beta.ics.uci.edu/dataset/69/molecular+biology+splice+junction+gene+sequences) from the [UCI repository](https://archive-beta.ics.uci.edu/).
20
+
21
+ # Configurations and tasks
22
+ | **Configuration** | **Task** |
23
+ |-------------------|---------------------------|
24
+ | splice | Multiclass classification |
25
+ | splice_EI | Binary classification |
26
+ | splice_IE | Binary classification |
27
+ | splice_N | Binary classification |
splice.data ADDED
The diff for this file is too large to render. See raw diff
 
splice.py ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Splice 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 = "Splice dataset."
16
+ _HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/69/molecular+biology+splice+junction+gene+sequences"
17
+ _URLS = ("https://archive-beta.ics.uci.edu/dataset/69/molecular+biology+splice+junction+gene+sequences")
18
+ _CITATION = """
19
+ @misc{misc_molecular_biology_(splice-junction_gene_sequences)_69,
20
+ title = {{Molecular Biology (Splice-junction Gene Sequences)}},
21
+ year = {1992},
22
+ howpublished = {UCI Machine Learning Repository},
23
+ note = {{DOI}: \\url{10.24432/C5M888}}
24
+ }
25
+ """
26
+
27
+ # Dataset info
28
+ urls_per_split = {
29
+ "train": "https://huggingface.co/datasets/mstz/splice/raw/main/splice.data"
30
+ }
31
+ features_types_per_config = {
32
+ "splice": {
33
+ "position_0": datasets.Value("string"),
34
+ "position_1": datasets.Value("string"),
35
+ "position_2": datasets.Value("string"),
36
+ "position_3": datasets.Value("string"),
37
+ "position_4": datasets.Value("string"),
38
+ "position_5": datasets.Value("string"),
39
+ "position_6": datasets.Value("string"),
40
+ "position_7": datasets.Value("string"),
41
+ "position_8": datasets.Value("string"),
42
+ "position_9": datasets.Value("string"),
43
+ "position_10": datasets.Value("string"),
44
+ "position_11": datasets.Value("string"),
45
+ "position_12": datasets.Value("string"),
46
+ "position_13": datasets.Value("string"),
47
+ "position_14": datasets.Value("string"),
48
+ "position_15": datasets.Value("string"),
49
+ "position_16": datasets.Value("string"),
50
+ "position_17": datasets.Value("string"),
51
+ "position_18": datasets.Value("string"),
52
+ "position_19": datasets.Value("string"),
53
+ "position_20": datasets.Value("string"),
54
+ "position_21": datasets.Value("string"),
55
+ "position_22": datasets.Value("string"),
56
+ "position_23": datasets.Value("string"),
57
+ "position_24": datasets.Value("string"),
58
+ "position_25": datasets.Value("string"),
59
+ "position_26": datasets.Value("string"),
60
+ "position_27": datasets.Value("string"),
61
+ "position_28": datasets.Value("string"),
62
+ "position_29": datasets.Value("string"),
63
+ "position_30": datasets.Value("string"),
64
+ "position_31": datasets.Value("string"),
65
+ "position_32": datasets.Value("string"),
66
+ "position_33": datasets.Value("string"),
67
+ "position_34": datasets.Value("string"),
68
+ "position_35": datasets.Value("string"),
69
+ "position_36": datasets.Value("string"),
70
+ "position_37": datasets.Value("string"),
71
+ "position_38": datasets.Value("string"),
72
+ "position_39": datasets.Value("string"),
73
+ "position_40": datasets.Value("string"),
74
+ "position_41": datasets.Value("string"),
75
+ "position_42": datasets.Value("string"),
76
+ "position_43": datasets.Value("string"),
77
+ "position_44": datasets.Value("string"),
78
+ "position_45": datasets.Value("string"),
79
+ "position_46": datasets.Value("string"),
80
+ "position_47": datasets.Value("string"),
81
+ "position_48": datasets.Value("string"),
82
+ "position_49": datasets.Value("string"),
83
+ "position_50": datasets.Value("string"),
84
+ "position_51": datasets.Value("string"),
85
+ "position_52": datasets.Value("string"),
86
+ "position_53": datasets.Value("string"),
87
+ "position_54": datasets.Value("string"),
88
+ "position_55": datasets.Value("string"),
89
+ "position_56": datasets.Value("string"),
90
+ "position_57": datasets.Value("string"),
91
+ "position_58": datasets.Value("string"),
92
+ "position_59": datasets.Value("string"),
93
+ "class": datasets.ClassLabel(num_classes=3, names=("EI", "IE", "N"))
94
+ },
95
+ "splice_EI": {
96
+ "position_0": datasets.Value("string"),
97
+ "position_1": datasets.Value("string"),
98
+ "position_2": datasets.Value("string"),
99
+ "position_3": datasets.Value("string"),
100
+ "position_4": datasets.Value("string"),
101
+ "position_5": datasets.Value("string"),
102
+ "position_6": datasets.Value("string"),
103
+ "position_7": datasets.Value("string"),
104
+ "position_8": datasets.Value("string"),
105
+ "position_9": datasets.Value("string"),
106
+ "position_10": datasets.Value("string"),
107
+ "position_11": datasets.Value("string"),
108
+ "position_12": datasets.Value("string"),
109
+ "position_13": datasets.Value("string"),
110
+ "position_14": datasets.Value("string"),
111
+ "position_15": datasets.Value("string"),
112
+ "position_16": datasets.Value("string"),
113
+ "position_17": datasets.Value("string"),
114
+ "position_18": datasets.Value("string"),
115
+ "position_19": datasets.Value("string"),
116
+ "position_20": datasets.Value("string"),
117
+ "position_21": datasets.Value("string"),
118
+ "position_22": datasets.Value("string"),
119
+ "position_23": datasets.Value("string"),
120
+ "position_24": datasets.Value("string"),
121
+ "position_25": datasets.Value("string"),
122
+ "position_26": datasets.Value("string"),
123
+ "position_27": datasets.Value("string"),
124
+ "position_28": datasets.Value("string"),
125
+ "position_29": datasets.Value("string"),
126
+ "position_30": datasets.Value("string"),
127
+ "position_31": datasets.Value("string"),
128
+ "position_32": datasets.Value("string"),
129
+ "position_33": datasets.Value("string"),
130
+ "position_34": datasets.Value("string"),
131
+ "position_35": datasets.Value("string"),
132
+ "position_36": datasets.Value("string"),
133
+ "position_37": datasets.Value("string"),
134
+ "position_38": datasets.Value("string"),
135
+ "position_39": datasets.Value("string"),
136
+ "position_40": datasets.Value("string"),
137
+ "position_41": datasets.Value("string"),
138
+ "position_42": datasets.Value("string"),
139
+ "position_43": datasets.Value("string"),
140
+ "position_44": datasets.Value("string"),
141
+ "position_45": datasets.Value("string"),
142
+ "position_46": datasets.Value("string"),
143
+ "position_47": datasets.Value("string"),
144
+ "position_48": datasets.Value("string"),
145
+ "position_49": datasets.Value("string"),
146
+ "position_50": datasets.Value("string"),
147
+ "position_51": datasets.Value("string"),
148
+ "position_52": datasets.Value("string"),
149
+ "position_53": datasets.Value("string"),
150
+ "position_54": datasets.Value("string"),
151
+ "position_55": datasets.Value("string"),
152
+ "position_56": datasets.Value("string"),
153
+ "position_57": datasets.Value("string"),
154
+ "position_58": datasets.Value("string"),
155
+ "position_59": datasets.Value("string"),
156
+ "is_ei": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
157
+ },
158
+ "splice_IE": {
159
+ "position_0": datasets.Value("string"),
160
+ "position_1": datasets.Value("string"),
161
+ "position_2": datasets.Value("string"),
162
+ "position_3": datasets.Value("string"),
163
+ "position_4": datasets.Value("string"),
164
+ "position_5": datasets.Value("string"),
165
+ "position_6": datasets.Value("string"),
166
+ "position_7": datasets.Value("string"),
167
+ "position_8": datasets.Value("string"),
168
+ "position_9": datasets.Value("string"),
169
+ "position_10": datasets.Value("string"),
170
+ "position_11": datasets.Value("string"),
171
+ "position_12": datasets.Value("string"),
172
+ "position_13": datasets.Value("string"),
173
+ "position_14": datasets.Value("string"),
174
+ "position_15": datasets.Value("string"),
175
+ "position_16": datasets.Value("string"),
176
+ "position_17": datasets.Value("string"),
177
+ "position_18": datasets.Value("string"),
178
+ "position_19": datasets.Value("string"),
179
+ "position_20": datasets.Value("string"),
180
+ "position_21": datasets.Value("string"),
181
+ "position_22": datasets.Value("string"),
182
+ "position_23": datasets.Value("string"),
183
+ "position_24": datasets.Value("string"),
184
+ "position_25": datasets.Value("string"),
185
+ "position_26": datasets.Value("string"),
186
+ "position_27": datasets.Value("string"),
187
+ "position_28": datasets.Value("string"),
188
+ "position_29": datasets.Value("string"),
189
+ "position_30": datasets.Value("string"),
190
+ "position_31": datasets.Value("string"),
191
+ "position_32": datasets.Value("string"),
192
+ "position_33": datasets.Value("string"),
193
+ "position_34": datasets.Value("string"),
194
+ "position_35": datasets.Value("string"),
195
+ "position_36": datasets.Value("string"),
196
+ "position_37": datasets.Value("string"),
197
+ "position_38": datasets.Value("string"),
198
+ "position_39": datasets.Value("string"),
199
+ "position_40": datasets.Value("string"),
200
+ "position_41": datasets.Value("string"),
201
+ "position_42": datasets.Value("string"),
202
+ "position_43": datasets.Value("string"),
203
+ "position_44": datasets.Value("string"),
204
+ "position_45": datasets.Value("string"),
205
+ "position_46": datasets.Value("string"),
206
+ "position_47": datasets.Value("string"),
207
+ "position_48": datasets.Value("string"),
208
+ "position_49": datasets.Value("string"),
209
+ "position_50": datasets.Value("string"),
210
+ "position_51": datasets.Value("string"),
211
+ "position_52": datasets.Value("string"),
212
+ "position_53": datasets.Value("string"),
213
+ "position_54": datasets.Value("string"),
214
+ "position_55": datasets.Value("string"),
215
+ "position_56": datasets.Value("string"),
216
+ "position_57": datasets.Value("string"),
217
+ "position_58": datasets.Value("string"),
218
+ "position_59": datasets.Value("string"),
219
+ "is_ie": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
220
+ },
221
+ "splice_N": {
222
+ "position_0": datasets.Value("string"),
223
+ "position_1": datasets.Value("string"),
224
+ "position_2": datasets.Value("string"),
225
+ "position_3": datasets.Value("string"),
226
+ "position_4": datasets.Value("string"),
227
+ "position_5": datasets.Value("string"),
228
+ "position_6": datasets.Value("string"),
229
+ "position_7": datasets.Value("string"),
230
+ "position_8": datasets.Value("string"),
231
+ "position_9": datasets.Value("string"),
232
+ "position_10": datasets.Value("string"),
233
+ "position_11": datasets.Value("string"),
234
+ "position_12": datasets.Value("string"),
235
+ "position_13": datasets.Value("string"),
236
+ "position_14": datasets.Value("string"),
237
+ "position_15": datasets.Value("string"),
238
+ "position_16": datasets.Value("string"),
239
+ "position_17": datasets.Value("string"),
240
+ "position_18": datasets.Value("string"),
241
+ "position_19": datasets.Value("string"),
242
+ "position_20": datasets.Value("string"),
243
+ "position_21": datasets.Value("string"),
244
+ "position_22": datasets.Value("string"),
245
+ "position_23": datasets.Value("string"),
246
+ "position_24": datasets.Value("string"),
247
+ "position_25": datasets.Value("string"),
248
+ "position_26": datasets.Value("string"),
249
+ "position_27": datasets.Value("string"),
250
+ "position_28": datasets.Value("string"),
251
+ "position_29": datasets.Value("string"),
252
+ "position_30": datasets.Value("string"),
253
+ "position_31": datasets.Value("string"),
254
+ "position_32": datasets.Value("string"),
255
+ "position_33": datasets.Value("string"),
256
+ "position_34": datasets.Value("string"),
257
+ "position_35": datasets.Value("string"),
258
+ "position_36": datasets.Value("string"),
259
+ "position_37": datasets.Value("string"),
260
+ "position_38": datasets.Value("string"),
261
+ "position_39": datasets.Value("string"),
262
+ "position_40": datasets.Value("string"),
263
+ "position_41": datasets.Value("string"),
264
+ "position_42": datasets.Value("string"),
265
+ "position_43": datasets.Value("string"),
266
+ "position_44": datasets.Value("string"),
267
+ "position_45": datasets.Value("string"),
268
+ "position_46": datasets.Value("string"),
269
+ "position_47": datasets.Value("string"),
270
+ "position_48": datasets.Value("string"),
271
+ "position_49": datasets.Value("string"),
272
+ "position_50": datasets.Value("string"),
273
+ "position_51": datasets.Value("string"),
274
+ "position_52": datasets.Value("string"),
275
+ "position_53": datasets.Value("string"),
276
+ "position_54": datasets.Value("string"),
277
+ "position_55": datasets.Value("string"),
278
+ "position_56": datasets.Value("string"),
279
+ "position_57": datasets.Value("string"),
280
+ "position_58": datasets.Value("string"),
281
+ "position_59": datasets.Value("string"),
282
+ "is_n": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
283
+ }
284
+ }
285
+ features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
286
+
287
+
288
+ class SpliceConfig(datasets.BuilderConfig):
289
+ def __init__(self, **kwargs):
290
+ super(SpliceConfig, self).__init__(version=VERSION, **kwargs)
291
+ self.features = features_per_config[kwargs["name"]]
292
+
293
+
294
+ class Splice(datasets.GeneratorBasedBuilder):
295
+ # dataset versions
296
+ DEFAULT_CONFIG = "splice1"
297
+ BUILDER_CONFIGS = [
298
+ SpliceConfig(name="splice",
299
+ description="Splice for multiclass classification."),
300
+ SpliceConfig(name="splice_IE",
301
+ description="Splice for binary classification."),
302
+ SpliceConfig(name="splice_EI",
303
+ description="Splice for binary classification."),
304
+ SpliceConfig(name="splice_N",
305
+ description="Splice for binary classification."),
306
+ ]
307
+
308
+
309
+ def _info(self):
310
+ info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
311
+ features=features_per_config[self.config.name])
312
+
313
+ return info
314
+
315
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
316
+ downloads = dl_manager.download_and_extract(urls_per_split)
317
+
318
+ return [
319
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads[self.config.name]["train"]}),
320
+ ]
321
+
322
+ def _generate_examples(self, filepath: str):
323
+ data = pandas.read_csv(filepath)
324
+ data = self.preprocess(data, config=self.config.name)
325
+
326
+ for row_id, row in data.iterrows():
327
+ data_row = dict(row)
328
+
329
+ yield row_id, data_row
330
+
331
+ def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
332
+ if self.config.name == "splice_IE":
333
+ data["class"] = data["class"].apply(lambda x: 1 if x == "IE" else 0)
334
+ data = data.rename(columns={"class", "is_ie"})
335
+ elif self.config.name == "splice_IE":
336
+ data["class"] = data["class"].apply(lambda x: 1 if x == "EI" else 0)
337
+ data = data.rename(columns={"class", "is_ei"})
338
+ elif self.config.name == "splice_N":
339
+ data["class"] = data["class"].apply(lambda x: 1 if x == "N" else 0)
340
+ data = data.rename(columns={"class", "is_n"})
341
+ else:
342
+ data["class"] = data["class"].apply(lambda x: {
343
+ "EI": 0,
344
+ "IE": 1,
345
+ "N": 2,
346
+ }[x])
347
+
348
+ for feature in _ENCODING_DICS:
349
+ encoding_function = partial(self.encode, feature)
350
+ data.loc[:, feature] = data[feature].apply(encoding_function)
351
+
352
+ return data[list(features_types_per_config[config].keys())]
353
+
354
+ def encode(self, feature, value):
355
+ if feature in _ENCODING_DICS:
356
+ return _ENCODING_DICS[feature][value]
357
+ raise ValueError(f"Unknown feature: {feature}")