|
"""TwoNorm""" |
|
|
|
from typing import List |
|
|
|
import datasets |
|
|
|
import pandas |
|
|
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
DESCRIPTION = "TwoNorm dataset from the OpenML repository." |
|
_HOMEPAGE = "https://www.openml.org/search?type=data&status=active&id=1507" |
|
_URLS = ("https://www.openml.org/search?type=data&status=active&id=1507") |
|
_CITATION = """""" |
|
|
|
|
|
urls_per_split = { |
|
"train": "https://huggingface.co/datasets/mstz/twonorm/raw/main/twonorm.csv" |
|
} |
|
features_types_per_config = { |
|
"twonorm": { |
|
"V1": datasets.Value("float64"), |
|
"V2": datasets.Value("float64"), |
|
"V3": datasets.Value("float64"), |
|
"V4": datasets.Value("float64"), |
|
"V5": datasets.Value("float64"), |
|
"V6": datasets.Value("float64"), |
|
"V7": datasets.Value("float64"), |
|
"V8": datasets.Value("float64"), |
|
"V9": datasets.Value("float64"), |
|
"V10": datasets.Value("float64"), |
|
"V11": datasets.Value("float64"), |
|
"V12": datasets.Value("float64"), |
|
"V13": datasets.Value("float64"), |
|
"V14": datasets.Value("float64"), |
|
"V15": datasets.Value("float64"), |
|
"V16": datasets.Value("float64"), |
|
"V17": datasets.Value("float64"), |
|
"V18": datasets.Value("float64"), |
|
"V19": datasets.Value("float64"), |
|
"V20": datasets.Value("float64"), |
|
"class": datasets.ClassLabel(num_classes=2, names=("no", "yes")) |
|
}, |
|
|
|
} |
|
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config} |
|
|
|
|
|
class TwoNormConfig(datasets.BuilderConfig): |
|
def __init__(self, **kwargs): |
|
super(TwoNormConfig, self).__init__(version=VERSION, **kwargs) |
|
self.features = features_per_config[kwargs["name"]] |
|
|
|
|
|
class TwoNorm(datasets.GeneratorBasedBuilder): |
|
|
|
DEFAULT_CONFIG = "twonorm" |
|
BUILDER_CONFIGS = [ |
|
TwoNormConfig(name="twonorm", |
|
description="TwoNorm for binary classification.") |
|
] |
|
|
|
|
|
def _info(self): |
|
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE, |
|
features=features_per_config[self.config.name]) |
|
|
|
return info |
|
|
|
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]: |
|
downloads = dl_manager.download_and_extract(urls_per_split) |
|
|
|
return [ |
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}) |
|
] |
|
|
|
def _generate_examples(self, filepath: str): |
|
data = pandas.read_csv(filepath) |
|
|
|
for row_id, row in data.iterrows(): |
|
data_row = dict(row) |
|
|
|
yield row_id, data_row |
|
|