Dmitry Filippov
commited on
Commit
·
a3f6c67
1
Parent(s):
c9ed105
Add dataset loading script
Browse files- wine-quality.py +31 -0
- winequality-red.csv +0 -0
- winequality-white.csv +0 -0
- winequality.names +1 -0
wine-quality.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import DatasetBuilder, Csv
|
2 |
+
import os
|
3 |
+
import csv
|
4 |
+
|
5 |
+
|
6 |
+
class WineQuality(DatasetBuilder):
|
7 |
+
VERSION = "1.0.0"
|
8 |
+
BUILDER_CONFIG_CLASS = Csv.BuilderConfig
|
9 |
+
BUILDER_CONFIGS = [
|
10 |
+
Csv.BuilderConfig(name="winequality-red", version=VERSION, delimiter=";", encoding="utf-8"),
|
11 |
+
Csv.BuilderConfig(name="winequality-white", version=VERSION, delimiter=";", encoding="utf-8"),
|
12 |
+
]
|
13 |
+
|
14 |
+
def _info(self):
|
15 |
+
return datasets.DatasetInfo(
|
16 |
+
description="This is the dataset of Wine Quality, including two kinds: red and white"
|
17 |
+
)
|
18 |
+
|
19 |
+
def _split_generators(self, dl_manager):
|
20 |
+
return [
|
21 |
+
datasets.SplitGenerator(name="red", gen_kwargs={"filepath": os.path.join(self.config.data_dir, "winequality-red.csv")}),
|
22 |
+
datasets.SplitGenerator(name="white", gen_kwargs={"filepath": os.path.join(self.config.data_dir, "winequality-white.csv")}),
|
23 |
+
]
|
24 |
+
|
25 |
+
def _generate_examples(self, filepath):
|
26 |
+
with open(filepath, encoding="utf-8") as f:
|
27 |
+
data = csv.DictReader(f)
|
28 |
+
for id_, row in enumerate(data):
|
29 |
+
yield id_, row
|
30 |
+
|
31 |
+
|
winequality-red.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
winequality-white.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
winequality.names
CHANGED
@@ -70,3 +70,4 @@ Citation Request:
|
|
70 |
12 - quality (score between 0 and 10)
|
71 |
|
72 |
8. Missing Attribute Values: None
|
|
|
|
70 |
12 - quality (score between 0 and 10)
|
71 |
|
72 |
8. Missing Attribute Values: None
|
73 |
+
|