Upload 3 files
Browse files- README.md +17 -0
- Wine_Quality_Data.csv +0 -0
- wine.py +107 -0
README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
tags:
|
| 5 |
+
- wine
|
| 6 |
+
- tabular_classification
|
| 7 |
+
- binary_classification
|
| 8 |
+
pretty_name: Compas
|
| 9 |
+
size_categories:
|
| 10 |
+
- 1K<n<10K
|
| 11 |
+
task_categories: # Full list at https://github.com/huggingface/hub-docs/blob/main/js/src/lib/interfaces/Types.ts
|
| 12 |
+
- tabular-classification
|
| 13 |
+
configs:
|
| 14 |
+
- wine
|
| 15 |
+
---
|
| 16 |
+
# Wine
|
| 17 |
+
The [Wine dataset](https://www.kaggle.com/datasets/ghassenkhaled/wine-quality-data) is cool.
|
Wine_Quality_Data.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
wine.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Wine Dataset"""
|
| 2 |
+
|
| 3 |
+
from typing import List
|
| 4 |
+
|
| 5 |
+
import datasets
|
| 6 |
+
|
| 7 |
+
import pandas
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
VERSION = datasets.Version("1.0.0")
|
| 11 |
+
_BASE_FEATURE_NAMES = [
|
| 12 |
+
"fixed_acidity",
|
| 13 |
+
"volatile_acidity",
|
| 14 |
+
"citric_acid",
|
| 15 |
+
"residual_sugar",
|
| 16 |
+
"chlorides",
|
| 17 |
+
"free_sulfur_dioxide",
|
| 18 |
+
"total_sulfur_dioxide",
|
| 19 |
+
"density",
|
| 20 |
+
"pH",
|
| 21 |
+
"sulphates",
|
| 22 |
+
"alcohol",
|
| 23 |
+
"quality",
|
| 24 |
+
"color"
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
DESCRIPTION = "Wine quality dataset."
|
| 29 |
+
_HOMEPAGE = "https://www.kaggle.com/datasets/ghassenkhaled/wine-quality-data"
|
| 30 |
+
_URLS = ("https://www.kaggle.com/datasets/ghassenkhaled/wine-quality-data")
|
| 31 |
+
_CITATION = """"""
|
| 32 |
+
|
| 33 |
+
# Dataset info
|
| 34 |
+
urls_per_split = {
|
| 35 |
+
"train": "https://huggingface.co/datasets/mstz/wine/raw/main/Wine_Quality_Data.csv",
|
| 36 |
+
}
|
| 37 |
+
features_types_per_config = {
|
| 38 |
+
"wine": {
|
| 39 |
+
"fixed_acidity": datasets.Value("float64"),
|
| 40 |
+
"volatile_acidity": datasets.Value("float64"),
|
| 41 |
+
"citric_acid": datasets.Value("float64"),
|
| 42 |
+
"residual_sugar": datasets.Value("float64"),
|
| 43 |
+
"chlorides": datasets.Value("float64"),
|
| 44 |
+
"free_sulfur_dioxide": datasets.Value("float64"),
|
| 45 |
+
"total_sulfur_dioxide": datasets.Value("float64"),
|
| 46 |
+
"density": datasets.Value("float64"),
|
| 47 |
+
"pH": datasets.Value("float64"),
|
| 48 |
+
"sulphates": datasets.Value("float64"),
|
| 49 |
+
"alcohol": datasets.Value("float64"),
|
| 50 |
+
"quality": datasets.Value("int8"),
|
| 51 |
+
"color": datasets.ClassLabel(num_classes=2, names=("red", "white"))
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
}
|
| 55 |
+
features_per_config = {k: datasets.Features(features_types_per_config[k]) for k in features_types_per_config}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
class WineConfig(datasets.BuilderConfig):
|
| 59 |
+
def __init__(self, **kwargs):
|
| 60 |
+
super(WineConfig, self).__init__(version=VERSION, **kwargs)
|
| 61 |
+
self.features = features_per_config[kwargs["name"]]
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
class Wine(datasets.GeneratorBasedBuilder):
|
| 65 |
+
# dataset versions
|
| 66 |
+
DEFAULT_CONFIG = "wine"
|
| 67 |
+
BUILDER_CONFIGS = [
|
| 68 |
+
WineConfig(name="wine",
|
| 69 |
+
description="Binary classification."),
|
| 70 |
+
]
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _info(self):
|
| 74 |
+
if self.config.name not in features_per_config:
|
| 75 |
+
raise ValueError(f"Unknown configuration: {self.config.name}")
|
| 76 |
+
|
| 77 |
+
info = datasets.DatasetInfo(description=DESCRIPTION, citation=_CITATION, homepage=_HOMEPAGE,
|
| 78 |
+
features=features_per_config[self.config.name])
|
| 79 |
+
|
| 80 |
+
return info
|
| 81 |
+
|
| 82 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
| 83 |
+
downloads = dl_manager.download_and_extract(urls_per_split)
|
| 84 |
+
|
| 85 |
+
return [
|
| 86 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloads["train"]}),
|
| 87 |
+
]
|
| 88 |
+
|
| 89 |
+
def _generate_examples(self, filepath: str):
|
| 90 |
+
data = pandas.read_csv(filepath)
|
| 91 |
+
data = self.preprocess(data, config=self.config.name)
|
| 92 |
+
|
| 93 |
+
for row_id, row in data.iterrows():
|
| 94 |
+
data_row = dict(row)
|
| 95 |
+
|
| 96 |
+
yield row_id, data_row
|
| 97 |
+
|
| 98 |
+
def preprocess(self, data: pandas.DataFrame, config: str = "wine") -> pandas.DataFrame:
|
| 99 |
+
data.loc[data.color == "red", "color"] = 0
|
| 100 |
+
data.loc[data.color == "white", "color"] = 1
|
| 101 |
+
|
| 102 |
+
data.columns = _BASE_FEATURE_NAMES
|
| 103 |
+
|
| 104 |
+
if config == "wine":
|
| 105 |
+
return data
|
| 106 |
+
else:
|
| 107 |
+
raise ValueError(f"Unknown config: {config}")
|