Datasets:
Tasks:
Tabular Classification
Modalities:
Tabular
Formats:
csv
Languages:
English
Size:
10K - 100K
License:
updated to datasets 4.*
Browse files- README.md +11 -10
- magic.py +0 -97
- magic04.data → magic/train.csv +0 -0
README.md
CHANGED
|
@@ -1,19 +1,20 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
-
- magic
|
| 6 |
- tabular_classification
|
| 7 |
- binary_classification
|
| 8 |
-
-
|
| 9 |
-
pretty_name: Magic
|
| 10 |
-
size_categories:
|
| 11 |
-
- 10K<n<100K
|
| 12 |
task_categories:
|
| 13 |
- tabular-classification
|
| 14 |
-
configs:
|
| 15 |
-
- magic
|
| 16 |
-
license: cc
|
| 17 |
---
|
| 18 |
# Magic
|
| 19 |
The [Magic dataset](https://archive.ics.uci.edu/ml/datasets/Magic) from the [UCI ML repository](https://archive.ics.uci.edu/ml/datasets).
|
|
|
|
| 1 |
---
|
| 2 |
+
configs:
|
| 3 |
+
- config_name: magic
|
| 4 |
+
data_files:
|
| 5 |
+
- path: magic/train.csv
|
| 6 |
+
split: train
|
| 7 |
+
default: true
|
| 8 |
+
language: en
|
| 9 |
+
license: cc
|
| 10 |
+
pretty_name: Magic
|
| 11 |
+
size_categories: 1M<n<10M
|
| 12 |
tags:
|
|
|
|
| 13 |
- tabular_classification
|
| 14 |
- binary_classification
|
| 15 |
+
- multiclass_classification
|
|
|
|
|
|
|
|
|
|
| 16 |
task_categories:
|
| 17 |
- tabular-classification
|
|
|
|
|
|
|
|
|
|
| 18 |
---
|
| 19 |
# Magic
|
| 20 |
The [Magic dataset](https://archive.ics.uci.edu/ml/datasets/Magic) from the [UCI ML repository](https://archive.ics.uci.edu/ml/datasets).
|
magic.py
DELETED
|
@@ -1,97 +0,0 @@
|
|
| 1 |
-
"""Magic"""
|
| 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 |
-
_BASE_FEATURE_NAMES = [
|
| 13 |
-
"major_axis_length",
|
| 14 |
-
"minor_axis_length",
|
| 15 |
-
"log_of_sum_of_content",
|
| 16 |
-
"ratio_of_sum_of_highest_pixels_and_size",
|
| 17 |
-
"ratio_of_highest_pixel_and_size",
|
| 18 |
-
"projected_distance_highest_to_center_pixel",
|
| 19 |
-
"third_root_of_third_moment_along_major_axis",
|
| 20 |
-
"third_root_of_third_moment_along_minor_axis",
|
| 21 |
-
"angle_major_axis_to_origin",
|
| 22 |
-
"distance_origin_to_center",
|
| 23 |
-
"class"
|
| 24 |
-
]
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
DESCRIPTION = "Magic dataset from the UCI ML repository."
|
| 28 |
-
_HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Magic"
|
| 29 |
-
_URLS = ("https://archive.ics.uci.edu/ml/datasets/Magic")
|
| 30 |
-
_CITATION = """
|
| 31 |
-
@misc{misc_magic_gamma_telescope_159,
|
| 32 |
-
author = {Bock,R.},
|
| 33 |
-
title = {{MAGIC Gamma Telescope}},
|
| 34 |
-
year = {2007},
|
| 35 |
-
howpublished = {UCI Machine Learning Repository},
|
| 36 |
-
note = {{DOI}: \\url{10.24432/C52C8B}}
|
| 37 |
-
}"""
|
| 38 |
-
|
| 39 |
-
# Dataset info
|
| 40 |
-
urls_per_split = {
|
| 41 |
-
"train": "https://huggingface.co/datasets/mstz/magic/raw/main/magic04.data"
|
| 42 |
-
}
|
| 43 |
-
features_types_per_config = {
|
| 44 |
-
"magic": {
|
| 45 |
-
"major_axis_length": datasets.Value("float64"),
|
| 46 |
-
"minor_axis_length": datasets.Value("float64"),
|
| 47 |
-
"log_of_sum_of_content": datasets.Value("float64"),
|
| 48 |
-
"ratio_of_sum_of_highest_pixels_and_size": datasets.Value("float64"),
|
| 49 |
-
"ratio_of_highest_pixel_and_size": datasets.Value("float64"),
|
| 50 |
-
"projected_distance_highest_to_center_pixel": datasets.Value("float64"),
|
| 51 |
-
"third_root_of_third_moment_along_major_axis": datasets.Value("float64"),
|
| 52 |
-
"third_root_of_third_moment_along_minor_axis": datasets.Value("float64"),
|
| 53 |
-
"angle_major_axis_to_origin": datasets.Value("float64"),
|
| 54 |
-
"distance_origin_to_center": datasets.Value("float64"),
|
| 55 |
-
"class": datasets.ClassLabel(num_classes=2, names=("no", "yes"))
|
| 56 |
-
}
|
| 57 |
-
}
|
| 58 |
-
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
class MagicConfig(datasets.BuilderConfig):
|
| 62 |
-
def __init__(self, **kwargs):
|
| 63 |
-
super(MagicConfig, self).__init__(version=VERSION, **kwargs)
|
| 64 |
-
self.features = features_per_config[kwargs["name"]]
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
class Magic(datasets.GeneratorBasedBuilder):
|
| 68 |
-
# dataset versions
|
| 69 |
-
DEFAULT_CONFIG = "magic"
|
| 70 |
-
BUILDER_CONFIGS = [
|
| 71 |
-
MagicConfig(name="magic",
|
| 72 |
-
description="Magic for binary classification.")
|
| 73 |
-
]
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
def _info(self):
|
| 77 |
-
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
| 78 |
-
features=features_per_config[self.config.name])
|
| 79 |
-
|
| 80 |
-
return info
|
| 81 |
-
|
| 82 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 83 |
-
downloads = dl_manager.download_and_extract(urls_per_split)
|
| 84 |
-
|
| 85 |
-
return [
|
| 86 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]})
|
| 87 |
-
]
|
| 88 |
-
|
| 89 |
-
def _generate_examples(self, filepath: str):
|
| 90 |
-
data = pandas.read_csv(filepath, header=None)
|
| 91 |
-
data.columns = _BASE_FEATURE_NAMES
|
| 92 |
-
data.loc[:, "class"] = data["class"].apply(lambda x: 1 if x == "g" else 0)
|
| 93 |
-
|
| 94 |
-
for row_id, row in data.iterrows():
|
| 95 |
-
data_row = dict(row)
|
| 96 |
-
|
| 97 |
-
yield row_id, data_row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
magic04.data → magic/train.csv
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|