Refactor script
Browse files- top_quark_tagging.py +17 -12
top_quark_tagging.py
CHANGED
|
@@ -44,11 +44,11 @@ _URLS = {
|
|
| 44 |
"test-labels": "data/test-labels.parquet",
|
| 45 |
},
|
| 46 |
"image": {
|
| 47 |
-
"train": "data/train-images.
|
| 48 |
"train-labels": "data/train-labels.parquet",
|
| 49 |
-
"validation": "data/train-images.
|
| 50 |
"validation-labels": "data/validation-labels.parquet",
|
| 51 |
-
"test": "data/train-images.
|
| 52 |
"test-labels": "data/test-labels.parquet",
|
| 53 |
},
|
| 54 |
}
|
|
@@ -890,7 +890,7 @@ class TopQuarkTagging(datasets.GeneratorBasedBuilder):
|
|
| 890 |
features = datasets.Features(features_data)
|
| 891 |
else:
|
| 892 |
features = datasets.Features(
|
| 893 |
-
{"
|
| 894 |
)
|
| 895 |
return datasets.DatasetInfo(
|
| 896 |
description=_DESCRIPTION,
|
|
@@ -923,12 +923,17 @@ class TopQuarkTagging(datasets.GeneratorBasedBuilder):
|
|
| 923 |
|
| 924 |
def _generate_examples(self, filepath, split):
|
| 925 |
"""Generate examples."""
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
yield id_, {**row, **label}
|
|
|
|
| 44 |
"test-labels": "data/test-labels.parquet",
|
| 45 |
},
|
| 46 |
"image": {
|
| 47 |
+
"train": "data/train-images.zip",
|
| 48 |
"train-labels": "data/train-labels.parquet",
|
| 49 |
+
"validation": "data/train-images.zip",
|
| 50 |
"validation-labels": "data/validation-labels.parquet",
|
| 51 |
+
"test": "data/train-images.zip",
|
| 52 |
"test-labels": "data/test-labels.parquet",
|
| 53 |
},
|
| 54 |
}
|
|
|
|
| 890 |
features = datasets.Features(features_data)
|
| 891 |
else:
|
| 892 |
features = datasets.Features(
|
| 893 |
+
{"file": datasets.Value("string"), "is_signal_new": datasets.ClassLabel(names=["qcd", "top"])}
|
| 894 |
)
|
| 895 |
return datasets.DatasetInfo(
|
| 896 |
description=_DESCRIPTION,
|
|
|
|
| 923 |
|
| 924 |
def _generate_examples(self, filepath, split):
|
| 925 |
"""Generate examples."""
|
| 926 |
+
if self.config.name == "image":
|
| 927 |
+
examples = pd.read_csv(f"{filepath[0]}/train-images/train.csv")
|
| 928 |
+
for row in examples.itertuples():
|
| 929 |
+
yield row.Index, {"file": f"{filepath[0]}/{row.file}", "is_signal_new": row.label}
|
| 930 |
+
else:
|
| 931 |
+
examples = datasets.load_dataset("parquet", data_files={split: filepath[0]}, split=split)
|
| 932 |
+
labels = datasets.load_dataset("parquet", data_files={split: filepath[1]}, split=split)
|
| 933 |
+
for id_, (row, label) in enumerate(zip(examples, labels)):
|
| 934 |
+
# if self.config.name == "image":
|
| 935 |
+
# values = np.fromiter(row.values(), dtype=float)
|
| 936 |
+
# image = values.reshape(33, 33)
|
| 937 |
+
# yield id_, {"image": image, **label}
|
| 938 |
+
# else:
|
| 939 |
yield id_, {**row, **label}
|