Datasets:
File size: 4,753 Bytes
5280ebb |
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 |
"""Promoters"""
from typing import List
from functools import partial
import datasets
import pandas
VERSION = datasets.Version("1.0.0")
DESCRIPTION = "Promoters dataset from the UCI ML repository."
_HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Promoters"
_URLS = ("https://archive.ics.uci.edu/ml/datasets/Promoters")
_CITATION = """
@misc{misc_molecular_biology_(promoter_gene_sequences)_67,
author = {Harley,C., Reynolds,R. & Noordewier,M.},
title = {{Molecular Biology (Promoter Gene Sequences)}},
year = {1990},
howpublished = {UCI Machine Learning Repository},
note = {{DOI}: \\url{10.24432/C5S01D}}
}"""
# Dataset info
urls_per_split = {
"train": "https://huggingface.co/datasets/mstz/promoters/raw/main/promoters.data"
}
features_types_per_config = {
"promoters": {
"seq_0": datasets.Value("string"),
"seq_1": datasets.Value("string"),
"seq_2": datasets.Value("string"),
"seq_3": datasets.Value("string"),
"seq_4": datasets.Value("string"),
"seq_5": datasets.Value("string"),
"seq_6": datasets.Value("string"),
"seq_7": datasets.Value("string"),
"seq_8": datasets.Value("string"),
"seq_9": datasets.Value("string"),
"seq_10": datasets.Value("string"),
"seq_11": datasets.Value("string"),
"seq_12": datasets.Value("string"),
"seq_13": datasets.Value("string"),
"seq_14": datasets.Value("string"),
"seq_15": datasets.Value("string"),
"seq_16": datasets.Value("string"),
"seq_17": datasets.Value("string"),
"seq_18": datasets.Value("string"),
"seq_19": datasets.Value("string"),
"seq_20": datasets.Value("string"),
"seq_21": datasets.Value("string"),
"seq_22": datasets.Value("string"),
"seq_23": datasets.Value("string"),
"seq_24": datasets.Value("string"),
"seq_25": datasets.Value("string"),
"seq_26": datasets.Value("string"),
"seq_27": datasets.Value("string"),
"seq_28": datasets.Value("string"),
"seq_29": datasets.Value("string"),
"seq_30": datasets.Value("string"),
"seq_31": datasets.Value("string"),
"seq_32": datasets.Value("string"),
"seq_33": datasets.Value("string"),
"seq_34": datasets.Value("string"),
"seq_35": datasets.Value("string"),
"seq_36": datasets.Value("string"),
"seq_37": datasets.Value("string"),
"seq_38": datasets.Value("string"),
"seq_39": datasets.Value("string"),
"seq_40": datasets.Value("string"),
"seq_41": datasets.Value("string"),
"seq_42": datasets.Value("string"),
"seq_43": datasets.Value("string"),
"seq_44": datasets.Value("string"),
"seq_45": datasets.Value("string"),
"seq_46": datasets.Value("string"),
"seq_47": datasets.Value("string"),
"seq_48": datasets.Value("string"),
"seq_49": datasets.Value("string"),
"seq_50": datasets.Value("string"),
"seq_51": datasets.Value("string"),
"seq_52": datasets.Value("string"),
"seq_53": datasets.Value("string"),
"seq_54": datasets.Value("string"),
"seq_55": datasets.Value("string"),
"seq_56": datasets.Value("string"),
"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 PromotersConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super(PromotersConfig, self).__init__(version=VERSION, **kwargs)
self.features = features_per_config[kwargs["name"]]
class Promoters(datasets.GeneratorBasedBuilder):
# dataset versions
DEFAULT_CONFIG = "promoters"
BUILDER_CONFIGS = [
PromotersConfig(name="promoters",
description="Promoters 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
|