File size: 2,678 Bytes
dd685b2
 
 
 
 
 
 
 
 
8d6d27c
 
dd685b2
 
 
 
 
 
 
 
eeee31f
dd685b2
eeee31f
dd685b2
eeee31f
dd685b2
 
 
 
 
99332c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd685b2
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
dataset_info:
  features:
  - name: text
    dtype: string
  - name: label
    dtype: string
  splits:
  - name: train
    num_examples: 196629
    num_bytes: 104709025
  - name: validation
    num_examples: 28090
  - name: test
    num_examples: 56181
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train.parquet
  - split: validation
    path: data/validation.parquet
  - split: test
    path: data/test.parquet
task_categories:
- text-classification
license: cc-by-nc-4.0
---

Dataset adapted from [spawn99/wine-reviews](https://huggingface.co/datasets/spawn99/wine-reviews/blob/main/README.md) to train classifiers on grape variety.  
Columns were consolidated to match the format described in [this project](https://github.com/ivanfioravanti/wine_variety_classification/blob/main/data_utils.py)  
```
import polars as pl
from datasets import load_dataset

ds_dict = load_dataset("spawn99/wine-reviews")

processed_splits = {}

for split_name, ds in ds_dict.items():
  print(f"Processing {split_name} split...")
  
  # Convert to Polars (Zero-copy via Arrow)
  df = pl.from_arrow(ds.data.table)

  # Apply transformation logic
  df_final = df.select([
    pl.format(
      "Based on this wine review, guess the grape variety:\n"
      "This wine is produced by {} in the {} region of {}.\n"
      "It was grown in {}. It is described as: \"{}\".\n"
      "The wine has been reviewed by {} and received {} points.\n"
      "The price is {}.",
      pl.col("winery").fill_null("a winery"),
      # Region logic: region_1 or province or region_2 or "Unknown region"
      pl.coalesce(["region_1", "province", "region_2"]).fill_null("Unknown region"),
      pl.col("country").fill_null("Unknown country"),
      pl.col("designation").fill_null("an unspecified appellation"),
      pl.col("description").fill_null("No description provided."),
      pl.col("taster_name").fill_null("a reviewer"),
      pl.col("points").cast(pl.String).fill_null("unrated"),
      # Price logic: cast to int to remove .0 then to string
      pl.col("price").cast(pl.Int64).cast(pl.String).fill_null("unknown")
    ).alias("text"),
    
    pl.col("variety").alias("label")
  ]).filter(pl.col("label").is_not_null())

  processed_splits[split_name] = df_final
  
  # Save locally or inspect
  print(f"Split {split_name} finished. Rows: {len(df_final)}")
  df_final.write_parquet(f"processed/{split_name}.parquet")
```

# Original Dataset Details

- **License:** [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
- **Attribution:** Zackthoutt
- **Source:** [Wine Reviews Dataset on Kaggle](https://www.kaggle.com/datasets/zynicide/wine-reviews)