File size: 6,389 Bytes
c63647d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | # coding=utf-8
# Copyright 2024 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""AAA-HiTSR: Multimodal Time Series Understanding Dataset"""
import json
import datasets
_CITATION = """\
@dataset{aaa_hitsr_2024,
title={AAA-HiTSR: A Comprehensive Multimodal Time Series Understanding Dataset},
year={2024}
}
"""
_DESCRIPTION = """\
AAA-HiTSR is a comprehensive multimodal time series understanding and reasoning dataset
with multiple complexity levels. It contains time series data paired with visual representations
and natural language instructions for time series analysis tasks.
"""
_HOMEPAGE = "https://huggingface.co/datasets/your-username/AAA-HiTSR"
_LICENSE = "cc-by-4.0"
_URLs = {
"train": [
"Train/l1_train_llatisa.json",
"Train/l2_train_llatisa.json",
"Train/l3_train_llatisa.json",
],
"test": [
"Test/l1_test_minmax.json",
"Test/l1_test_multiseries.json",
"Test/l1_test_startend.json",
"Test/l1_test_subseries.json",
"Test/l2_test_global.json",
"Test/l2_test_local.json",
"Test/l2_test_numerical.json",
"Test/l3_test.json",
],
}
class AAAHiTSRConfig(datasets.BuilderConfig):
"""Builder config for AAA-HiTSR dataset."""
def __init__(self, name, description, **kwargs):
super(AAAHiTSRConfig, self).__init__(**kwargs)
self.description = description
class AAAHiTSR(datasets.GeneratorBasedBuilder):
"""AAA-HiTSR: Multimodal Time Series Understanding Dataset"""
BUILDER_CONFIGS = [
AAAHiTSRConfig(
name="all",
description="All levels of the AAA-HiTSR dataset",
version=datasets.Version("1.0.0"),
),
AAAHiTSRConfig(
name="level1",
description="Level 1 (Basic) - Single series analysis",
version=datasets.Version("1.0.0"),
),
AAAHiTSRConfig(
name="level2",
description="Level 2 (Intermediate) - Multi-series analysis",
version=datasets.Version("1.0.0"),
),
AAAHiTSRConfig(
name="level3",
description="Level 3 (Advanced) - Complex reasoning",
version=datasets.Version("1.0.0"),
),
]
DEFAULT_CONFIG_NAME = "all"
def _info(self):
if self.config.name == "all":
features = datasets.Features(
{
"id": datasets.Value("int32"),
"level": datasets.Value("string"),
"split": datasets.Value("string"),
"timeseries": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
"prompt": datasets.Value("string"),
"answer": datasets.Value("string"),
"2img_prompt": datasets.Value("string"),
"prompt_1": datasets.Value("string"),
"prompt_2": datasets.Value("string"),
"answer_1": datasets.Value("string"),
"answer_2": datasets.Value("string"),
"images": datasets.Sequence(datasets.Value("string")),
}
)
else:
features = datasets.Features(
{
"id": datasets.Value("int32"),
"timeseries": datasets.Sequence(datasets.Sequence(datasets.Value("float32"))),
"prompt": datasets.Value("string"),
"answer": datasets.Value("string"),
"2img_prompt": datasets.Value("string"),
"prompt_1": datasets.Value("string"),
"prompt_2": datasets.Value("string"),
"answer_1": datasets.Value("string"),
"answer_2": datasets.Value("string"),
"images": datasets.Sequence(datasets.Value("string")),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
"""Returns SplitGenerators."""
urls_to_download = _URLs
downloaded_files = dl_manager.download(urls_to_download)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"filepaths": downloaded_files["train"],
"split": "train"
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepaths": downloaded_files["test"],
"split": "test"
},
),
]
def _generate_examples(self, filepaths, split):
"""Yields examples."""
example_id = 0
for filepath in filepaths:
# Determine level and dataset type from filepath
if "l1_" in filepath:
level = "level1"
elif "l2_" in filepath:
level = "level2"
elif "l3_" in filepath:
level = "level3"
else:
level = "unknown"
with open(filepath, encoding="utf-8") as f:
data = json.load(f)
# Handle both single items and lists
if isinstance(data, dict):
data = [data]
for item in data:
if self.config.name == "all":
item["level"] = level
item["split"] = split
yield example_id, item
example_id += 1
|