Datasets:
File size: 6,387 Bytes
dc4d7e5 |
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 |
"""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
|