feat: add task info/ allow for val set
Browse files- agro-nt-tasks.py +30 -14
agro-nt-tasks.py
CHANGED
@@ -52,11 +52,12 @@ _TASK_NAMES = ['poly_a.arabidopsis_thaliana',
|
|
52 |
]
|
53 |
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
|
|
60 |
|
61 |
class AgroNtTasksConfig(datasets.BuilderConfig):
|
62 |
"""BuilderConfig for the Agro NT supervised learning tasks dataset."""
|
@@ -69,7 +70,8 @@ class AgroNtTasksConfig(datasets.BuilderConfig):
|
|
69 |
"""
|
70 |
|
71 |
self.task,self.sub_task = task_name.split(".")
|
72 |
-
self.task_type =
|
|
|
73 |
|
74 |
super().__init__(
|
75 |
*args,
|
@@ -97,6 +99,14 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
|
97 |
"label": datasets.Value("int8"),
|
98 |
}
|
99 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
return datasets.DatasetInfo(
|
102 |
# This is the description that will appear on the datasets page.
|
@@ -116,7 +126,7 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
|
116 |
test_file = dl_manager.download_and_extract(
|
117 |
os.path.join(self.config.task, self.config.sub_task + "_test.fa"))
|
118 |
|
119 |
-
|
120 |
datasets.SplitGenerator(
|
121 |
name=datasets.Split.TRAIN,
|
122 |
# These kwargs will be passed to _generate_examples
|
@@ -124,14 +134,6 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
|
124 |
"filepath": train_file,
|
125 |
},
|
126 |
),
|
127 |
-
# datasets.SplitGenerator(
|
128 |
-
# name=datasets.Split.VALIDATION,
|
129 |
-
# # These kwargs will be passed to _generate_examples
|
130 |
-
# gen_kwargs={
|
131 |
-
# "filepath": test_file,
|
132 |
-
# "split": "dev",
|
133 |
-
# },
|
134 |
-
# ),
|
135 |
datasets.SplitGenerator(
|
136 |
name=datasets.Split.TEST,
|
137 |
# These kwargs will be passed to _generate_examples
|
@@ -141,6 +143,20 @@ class AgroNtTasks(datasets.GeneratorBasedBuilder):
|
|
141 |
),
|
142 |
]
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
145 |
def _generate_examples(self, filepath):
|
146 |
with open(filepath, 'r') as f:
|
|
|
52 |
]
|
53 |
|
54 |
|
55 |
+
_TASK_INFO = {'poly_a':{'type': 'binary', 'val_set':False},
|
56 |
+
'splicing':{'type': 'binary', 'val_set':False},
|
57 |
+
'lncrna':{'type': 'binary', 'val_set':False},
|
58 |
+
'promoter_strength': {'type': 'regression', 'val_set': True},
|
59 |
|
60 |
+
}
|
61 |
|
62 |
class AgroNtTasksConfig(datasets.BuilderConfig):
|
63 |
"""BuilderConfig for the Agro NT supervised learning tasks dataset."""
|
|
|
70 |
"""
|
71 |
|
72 |
self.task,self.sub_task = task_name.split(".")
|
73 |
+
self.task_type = _TASK_INFO[self.task['type']]
|
74 |
+
self.val_set = _TASK_INFO[self.task['val_set']]
|
75 |
|
76 |
super().__init__(
|
77 |
*args,
|
|
|
99 |
"label": datasets.Value("int8"),
|
100 |
}
|
101 |
)
|
102 |
+
elif self.config.task_type == 'regression':
|
103 |
+
features = datasets.Features(
|
104 |
+
{
|
105 |
+
"sequence": datasets.Value("string"),
|
106 |
+
"name": datasets.Value("string"),
|
107 |
+
"label": datasets.Value("float32"),
|
108 |
+
}
|
109 |
+
)
|
110 |
|
111 |
return datasets.DatasetInfo(
|
112 |
# This is the description that will appear on the datasets page.
|
|
|
126 |
test_file = dl_manager.download_and_extract(
|
127 |
os.path.join(self.config.task, self.config.sub_task + "_test.fa"))
|
128 |
|
129 |
+
generator_list = [
|
130 |
datasets.SplitGenerator(
|
131 |
name=datasets.Split.TRAIN,
|
132 |
# These kwargs will be passed to _generate_examples
|
|
|
134 |
"filepath": train_file,
|
135 |
},
|
136 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
datasets.SplitGenerator(
|
138 |
name=datasets.Split.TEST,
|
139 |
# These kwargs will be passed to _generate_examples
|
|
|
143 |
),
|
144 |
]
|
145 |
|
146 |
+
if self.config.val_set:
|
147 |
+
validation_file = dl_manager.download_and_extract(
|
148 |
+
os.path.join(self.config.task, self.config.sub_task + "_validation.fa"))
|
149 |
+
|
150 |
+
generator_list += datasets.SplitGenerator(
|
151 |
+
name=datasets.Split.VALIDATION,
|
152 |
+
# These kwargs will be passed to _generate_examples
|
153 |
+
gen_kwargs={
|
154 |
+
"filepath": validation_file,
|
155 |
+
},
|
156 |
+
),
|
157 |
+
|
158 |
+
return generator_list
|
159 |
+
|
160 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
161 |
def _generate_examples(self, filepath):
|
162 |
with open(filepath, 'r') as f:
|