from typing import List import datasets import pandas VERSION = datasets.Version("1.0.0") DESCRIPTION = "Covertype dataset from the UCI ML repository." _HOMEPAGE = "https://archive-beta.ics.uci.edu/dataset/31/covertype" _URLS = ("https://archive-beta.ics.uci.edu/dataset/31/covertype") _CITATION = """ @misc{misc_covertype_31, author = {Blackard,Jock}, title = {{Covertype}}, year = {1998}, howpublished = {UCI Machine Learning Repository}, note = {{DOI}: \\url{10.24432/C50K5N}} } """ # Dataset info urls_per_split = { "train": "https://archive.ics.uci.edu/ml/machine-learning-databases/covtype/covtype.data.gz" } _BASE_FEATURE_NAMES = [ "elevation", "aspect", "slope", "horizontal_distance_to_hydrology", "vertical_distance_to_hydrology", "horizontal_distance_to_roadways", "hillshade_9am", "hillshade_noon", "hillshade_3pm", "horizontal_distance_to_fire_points", "wilderness_area_id_0", "wilderness_area_id_1", "wilderness_area_id_2", "wilderness_area_id_3", "soil_type_id_0", "soil_type_id_1", "soil_type_id_2", "soil_type_id_3", "soil_type_id_4", "soil_type_id_5", "soil_type_id_6", "soil_type_id_7", "soil_type_id_8", "soil_type_id_9", "soil_type_id_10", "soil_type_id_11", "soil_type_id_12", "soil_type_id_13", "soil_type_id_14", "soil_type_id_15", "soil_type_id_16", "soil_type_id_17", "soil_type_id_18", "soil_type_id_19", "soil_type_id_20", "soil_type_id_21", "soil_type_id_22", "soil_type_id_23", "soil_type_id_24", "soil_type_id_25", "soil_type_id_26", "soil_type_id_27", "soil_type_id_28", "soil_type_id_29", "soil_type_id_30", "soil_type_id_31", "soil_type_id_32", "soil_type_id_33", "soil_type_id_34", "soil_type_id_35", "soil_type_id_36", "soil_type_id_37", "soil_type_id_38", "soil_type_id_39", "cover_type" ] features_types_per_config = { "covertype": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=7) }, "covertype_0": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_1": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_2": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_3": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_4": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_5": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) }, "covertype_6": { "elevation": datasets.Value("float32"), "aspect": datasets.Value("float32"), "slope": datasets.Value("float32"), "horizontal_distance_to_hydrology": datasets.Value("float32"), "vertical_distance_to_hydrology": datasets.Value("float32"), "horizontal_distance_to_roadways": datasets.Value("float32"), "hillshade_9am": datasets.Value("float32"), "hillshade_noon": datasets.Value("float32"), "hillshade_3pm": datasets.Value("float32"), "horizontal_distance_to_fire_points": datasets.Value("float32"), "wilderness_area_id_0": datasets.Value("bool"), "wilderness_area_id_1": datasets.Value("bool"), "wilderness_area_id_2": datasets.Value("bool"), "wilderness_area_id_3": datasets.Value("bool"), "soil_type_id_0": datasets.Value("bool"), "soil_type_id_1": datasets.Value("bool"), "soil_type_id_2": datasets.Value("bool"), "soil_type_id_3": datasets.Value("bool"), "soil_type_id_4": datasets.Value("bool"), "soil_type_id_5": datasets.Value("bool"), "soil_type_id_6": datasets.Value("bool"), "soil_type_id_7": datasets.Value("bool"), "soil_type_id_8": datasets.Value("bool"), "soil_type_id_9": datasets.Value("bool"), "soil_type_id_10": datasets.Value("bool"), "soil_type_id_11": datasets.Value("bool"), "soil_type_id_12": datasets.Value("bool"), "soil_type_id_13": datasets.Value("bool"), "soil_type_id_14": datasets.Value("bool"), "soil_type_id_15": datasets.Value("bool"), "soil_type_id_16": datasets.Value("bool"), "soil_type_id_17": datasets.Value("bool"), "soil_type_id_18": datasets.Value("bool"), "soil_type_id_19": datasets.Value("bool"), "soil_type_id_20": datasets.Value("bool"), "soil_type_id_21": datasets.Value("bool"), "soil_type_id_22": datasets.Value("bool"), "soil_type_id_23": datasets.Value("bool"), "soil_type_id_24": datasets.Value("bool"), "soil_type_id_25": datasets.Value("bool"), "soil_type_id_26": datasets.Value("bool"), "soil_type_id_27": datasets.Value("bool"), "soil_type_id_28": datasets.Value("bool"), "soil_type_id_29": datasets.Value("bool"), "soil_type_id_30": datasets.Value("bool"), "soil_type_id_31": datasets.Value("bool"), "soil_type_id_32": datasets.Value("bool"), "soil_type_id_33": datasets.Value("bool"), "soil_type_id_34": datasets.Value("bool"), "soil_type_id_35": datasets.Value("bool"), "soil_type_id_36": datasets.Value("bool"), "soil_type_id_37": datasets.Value("bool"), "soil_type_id_38": datasets.Value("bool"), "soil_type_id_39": datasets.Value("bool"), "cover_type": datasets.ClassLabel(num_classes=2) } } features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config} class CovertypeConfig(datasets.BuilderConfig): def __init__(self, **kwargs): super(CovertypeConfig, self).__init__(version=VERSION, **kwargs) self.features = features_per_config[kwargs["name"]] class Covertype(datasets.GeneratorBasedBuilder): # dataset versions DEFAULT_CONFIG = "covertype" BUILDER_CONFIGS = [ CovertypeConfig(name="covertype", description="Covertype for multiclass classification."), CovertypeConfig(name="covertype_0", description="Covertype for binary classification."), CovertypeConfig(name="covertype_1", description="Covertype for binary classification."), CovertypeConfig(name="covertype_2", description="Covertype for binary classification."), CovertypeConfig(name="covertype_3", description="Covertype for binary classification."), CovertypeConfig(name="covertype_4", description="Covertype for binary classification."), CovertypeConfig(name="covertype_5", description="Covertype for binary classification."), CovertypeConfig(name="covertype_6", description="Covertype for binary classification."), ] def _info(self): if self.config.name not in features_per_config: raise ValueError(f"Unknown configuration: {self.config.name}") 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): # with gzip.open(filepath) as log: # data = pandas.read_csv(log", header=None) data = pandas.read_csv(filepath, header=None) data.columns = _BASE_FEATURE_NAMES data = self.preprocess(data, config=self.config.name) for row_id, row in data.iterrows(): data_row = dict(row) yield row_id, data_row def preprocess(self, data: pandas.DataFrame, config: str = DEFAULT_CONFIG) -> pandas.DataFrame: data["cover_type"] = data["cover_type"].apply(lambda x: x - 1) if config == "covertype_0": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 0 else 0) elif config == "covertype_1": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 1 else 0) elif config == "covertype_2": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 2 else 0) elif config == "covertype_3": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 3 else 0) elif config == "covertype_4": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 4 else 0) elif config == "covertype_5": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 5 else 0) elif config == "covertype_6": data["cover_type"] = data["cover_type"].apply(lambda x: 1 if x == 6 else 0) return data