|
"""Planning: A Census Dataset""" |
|
|
|
from typing import List |
|
|
|
import datasets |
|
|
|
import pandas |
|
|
|
|
|
VERSION = datasets.Version("1.0.0") |
|
_BASE_FEATURE_NAMES = [ |
|
"V1", |
|
"V2", |
|
"V3", |
|
"V4", |
|
"V5", |
|
"V6", |
|
"V7", |
|
"V8", |
|
"V9", |
|
"V10", |
|
"V11", |
|
"V12", |
|
"class" |
|
] |
|
|
|
DESCRIPTION = "Planning dataset from the UCI ML repository." |
|
_HOMEPAGE = "https://archive.ics.uci.edu/ml/datasets/Planning" |
|
_URLS = ("https://archive.ics.uci.edu/ml/datasets/Planning") |
|
_CITATION = """ |
|
@misc{misc_planning_relax_230, |
|
author = {Bhatt,Rajen}, |
|
title = {{Planning Relax}}, |
|
year = {2012}, |
|
howpublished = {UCI Machine Learning Repository}, |
|
note = {{DOI}: \\url{10.24432/C5T023}} |
|
}""" |
|
|
|
|
|
urls_per_split = { |
|
"planning": {"train": "https://huggingface.co/datasets/mstz/planning/raw/main/plrx.csv"} |
|
} |
|
features_types_per_config = { |
|
"planning": { |
|
"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"), |
|
"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 PlanningConfig(datasets.BuilderConfig): |
|
def __init__(self, **kwargs): |
|
super(PlanningConfig, self).__init__(version=VERSION, **kwargs) |
|
self.features = features_per_config[kwargs["name"]] |
|
|
|
|
|
class Planning(datasets.GeneratorBasedBuilder): |
|
|
|
DEFAULT_CONFIG = "planning" |
|
BUILDER_CONFIGS = [ |
|
PlanningConfig(name="planning", |
|
description="Planning 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[self.config.name]["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 |
|
|