|
import csv |
|
import os |
|
import pandas as pd |
|
from datasets import GeneratorBasedBuilder, DatasetInfo, SplitGenerator, Split |
|
|
|
class WineQuality(GeneratorBasedBuilder): |
|
VERSION = "1.0.0" |
|
|
|
def _info(self): |
|
return DatasetInfo( |
|
description="This is the dataset of Wine Quality, it consists of two parts: red and white" |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
filepaths = dl_manager.download_and_extract({ |
|
"red": "winequality-red.csv", |
|
"white": "winequality-white.csv" |
|
}) |
|
return [ |
|
SplitGenerator(name="red", gen_kwargs={"filepath": filepaths["red"]}), |
|
SplitGenerator(name="white", gen_kwargs={"filepath": filepaths["white"]}), |
|
] |
|
|
|
def _generate_examples(self, filepath): |
|
df = pd.read_csv(filepath, delimiter=";") |
|
for id_, row in df.iterrows(): |
|
yield id_, row.to_dict() |
|
|