USPS / load_script.py
Witold Wydmański
feat: update
d86b2fe
raw
history blame contribute delete
No virus
1.95 kB
import datasets
from datasets.tasks import TaskTemplate
from sklearn.model_selection import train_test_split
_ORIGIN = "https://ieeexplore.ieee.org/document/291440"
_CITATION = """\
J. J. Hull, "A database for handwritten text recognition research," in IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 16, no. 5, pp. 550-554, May 1994, doi: 10.1109/34.291440.
"""
_DESCRIPTION = """\
An image database for handwritten text recognition research is described. Digital images of approximately 5000 city names, 5000 state names, 10000 ZIP Codes, and 50000 alphanumeric characters are included. Each image was scanned from mail in a working post office at 300 pixels/in in 8-bit gray scale on a high-quality flat bed digitizer. The data were unconstrained for the writer, style, and method of preparation. These characteristics help overcome the limitations of earlier databases that contained only isolated characters or were prepared in a laboratory setting under prescribed circumstances. Also, the database is divided into explicit training and testing sets to facilitate the sharing of results among researchers as well as performance comparisons."""
class WisconsinBreastCancer(datasets.GeneratorBasedBuilder):
def _info(self) -> datasets.DatasetInfo:
return datasets.DatasetInfo(
description=_DESCRIPTION,
citation=_CITATION,
homepage=_ORIGIN,
license="",
)
def _split_generators(self, dl_manager):
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": "train.csv"}),
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": "test.csv"}),
]
def _generate_examples(self, filepath):
with open(filepath, "r") as f:
next(f)
for key, row in enumerate(f):
yield key, {"data": row[:-1], "label": row[-1]}