"""Hill""" from typing import List import datasets import pandas VERSION = datasets.Version("1.0.0") DESCRIPTION = "Hill dataset from the UCI ML repository." _HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Hill" _URLS = ("https://archive.ics.uci.edu/ml/datasets/Hill") _CITATION = """ @misc{misc_hill-valley_166, author = {Graham,Lee & Oppacher,Franz}, title = {{Hill-Valley}}, year = {2008}, howpublished = {UCI Machine Learning Repository}, note = {{DOI}: \\url{10.24432/C5JC8P}} }""" # Dataset info urls_per_split = { "train": "Hill_Valley_without_noise_Training.data", "test": "Hill_Valley_without_noise_Testing.data" } features_types_per_config = { "hill": { "X1": datasets.Value("float64"), "X2": datasets.Value("float64"), "X3": datasets.Value("float64"), "X4": datasets.Value("float64"), "X5": datasets.Value("float64"), "X6": datasets.Value("float64"), "X7": datasets.Value("float64"), "X8": datasets.Value("float64"), "X9": datasets.Value("float64"), "X10": datasets.Value("float64"), "X11": datasets.Value("float64"), "X12": datasets.Value("float64"), "X13": datasets.Value("float64"), "X14": datasets.Value("float64"), "X15": datasets.Value("float64"), "X16": datasets.Value("float64"), "X17": datasets.Value("float64"), "X18": datasets.Value("float64"), "X19": datasets.Value("float64"), "X20": datasets.Value("float64"), "X21": datasets.Value("float64"), "X22": datasets.Value("float64"), "X23": datasets.Value("float64"), "X24": datasets.Value("float64"), "X25": datasets.Value("float64"), "X26": datasets.Value("float64"), "X27": datasets.Value("float64"), "X28": datasets.Value("float64"), "X29": datasets.Value("float64"), "X30": datasets.Value("float64"), "X31": datasets.Value("float64"), "X32": datasets.Value("float64"), "X33": datasets.Value("float64"), "X34": datasets.Value("float64"), "X35": datasets.Value("float64"), "X36": datasets.Value("float64"), "X37": datasets.Value("float64"), "X38": datasets.Value("float64"), "X39": datasets.Value("float64"), "X40": datasets.Value("float64"), "X41": datasets.Value("float64"), "X42": datasets.Value("float64"), "X43": datasets.Value("float64"), "X44": datasets.Value("float64"), "X45": datasets.Value("float64"), "X46": datasets.Value("float64"), "X47": datasets.Value("float64"), "X48": datasets.Value("float64"), "X49": datasets.Value("float64"), "X50": datasets.Value("float64"), "X51": datasets.Value("float64"), "X52": datasets.Value("float64"), "X53": datasets.Value("float64"), "X54": datasets.Value("float64"), "X55": datasets.Value("float64"), "X56": datasets.Value("float64"), "X57": datasets.Value("float64"), "X58": datasets.Value("float64"), "X59": datasets.Value("float64"), "X60": datasets.Value("float64"), "X61": datasets.Value("float64"), "X62": datasets.Value("float64"), "X63": datasets.Value("float64"), "X64": datasets.Value("float64"), "X65": datasets.Value("float64"), "X66": datasets.Value("float64"), "X67": datasets.Value("float64"), "X68": datasets.Value("float64"), "X69": datasets.Value("float64"), "X70": datasets.Value("float64"), "X71": datasets.Value("float64"), "X72": datasets.Value("float64"), "X73": datasets.Value("float64"), "X74": datasets.Value("float64"), "X75": datasets.Value("float64"), "X76": datasets.Value("float64"), "X77": datasets.Value("float64"), "X78": datasets.Value("float64"), "X79": datasets.Value("float64"), "X80": datasets.Value("float64"), "X81": datasets.Value("float64"), "X82": datasets.Value("float64"), "X83": datasets.Value("float64"), "X84": datasets.Value("float64"), "X85": datasets.Value("float64"), "X86": datasets.Value("float64"), "X87": datasets.Value("float64"), "X88": datasets.Value("float64"), "X89": datasets.Value("float64"), "X90": datasets.Value("float64"), "X91": datasets.Value("float64"), "X92": datasets.Value("float64"), "X93": datasets.Value("float64"), "X94": datasets.Value("float64"), "X95": datasets.Value("float64"), "X96": datasets.Value("float64"), "X97": datasets.Value("float64"), "X98": datasets.Value("float64"), "X99": datasets.Value("float64"), "X100": datasets.Value("float64"), "class": datasets.ClassLabel(num_classes=2) } } features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config} class HillConfig(datasets.BuilderConfig): def __init__(self, **kwargs): super(HillConfig, self).__init__(version=VERSION, **kwargs) self.features = features_per_config[kwargs["name"]] class Hill(datasets.GeneratorBasedBuilder): # dataset versions DEFAULT_CONFIG = "hill" BUILDER_CONFIGS = [ HillConfig(name="hill", description="Hill 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"]}), datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloads["test"]}), ] 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