streamline splits
Browse files- cloudops_tsf.py +21 -31
cloudops_tsf.py
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
# limitations under the License.
|
14 |
from dataclasses import dataclass, field
|
15 |
from typing import Iterator, Optional
|
16 |
-
from functools import cached_property
|
17 |
|
18 |
import datasets
|
19 |
import pandas as pd
|
@@ -157,19 +156,12 @@ class CloudOpsTSFConfig(datasets.BuilderConfig):
|
|
157 |
feat_static_real_dim: int = field(default=0)
|
158 |
past_feat_dynamic_real_dim: int = field(default=0)
|
159 |
|
160 |
-
|
161 |
-
|
|
|
162 |
if FieldName.FEAT_STATIC_CAT not in self.optional_fields:
|
163 |
return None
|
164 |
|
165 |
-
if self.pretrain:
|
166 |
-
split = "pretrain"
|
167 |
-
elif self.train_test:
|
168 |
-
split = "train_test"
|
169 |
-
else:
|
170 |
-
raise ValueError(
|
171 |
-
"At least one of `train_test` and `pretrain` should be True"
|
172 |
-
)
|
173 |
return [c[1] for c in self._feat_static_cat_cardinalities[split]]
|
174 |
|
175 |
|
@@ -239,26 +231,24 @@ class CloudOpsTSF(datasets.ArrowBasedBuilder):
|
|
239 |
)
|
240 |
|
241 |
def _split_generators(self, dl_manager) -> list[datasets.SplitGenerator]:
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
f"{self.config.name}/
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
)
|
261 |
-
)
|
262 |
return generators
|
263 |
|
264 |
def _generate_tables(self, filepath: str) -> Iterator[pa.Table]:
|
|
|
13 |
# limitations under the License.
|
14 |
from dataclasses import dataclass, field
|
15 |
from typing import Iterator, Optional
|
|
|
16 |
|
17 |
import datasets
|
18 |
import pandas as pd
|
|
|
156 |
feat_static_real_dim: int = field(default=0)
|
157 |
past_feat_dynamic_real_dim: int = field(default=0)
|
158 |
|
159 |
+
def feat_static_cat_cardinalities(
|
160 |
+
self, split: str = "train_test"
|
161 |
+
) -> Optional[list[int]]:
|
162 |
if FieldName.FEAT_STATIC_CAT not in self.optional_fields:
|
163 |
return None
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
return [c[1] for c in self._feat_static_cat_cardinalities[split]]
|
166 |
|
167 |
|
|
|
231 |
)
|
232 |
|
233 |
def _split_generators(self, dl_manager) -> list[datasets.SplitGenerator]:
|
234 |
+
downloaded_files = dl_manager.download_and_extract(
|
235 |
+
[
|
236 |
+
f"{self.config.name}/train_test.zip",
|
237 |
+
f"{self.config.name}/pretrain.zip",
|
238 |
+
]
|
239 |
+
)
|
240 |
+
|
241 |
+
generators = [
|
242 |
+
datasets.SplitGenerator(
|
243 |
+
name=TRAIN_TEST,
|
244 |
+
gen_kwargs={"filepath": downloaded_files[0]},
|
245 |
+
),
|
246 |
+
datasets.SplitGenerator(
|
247 |
+
name=PRETRAIN,
|
248 |
+
gen_kwargs={"filepath": downloaded_files[1]},
|
249 |
+
),
|
250 |
+
]
|
251 |
+
|
|
|
|
|
252 |
return generators
|
253 |
|
254 |
def _generate_tables(self, filepath: str) -> Iterator[pa.Table]:
|