Unso commited on
Commit
110a135
1 Parent(s): 0fb81fc

0 indexing the labels

Browse files
Files changed (1) hide show
  1. create_dataset.py +2 -1
create_dataset.py CHANGED
@@ -6,11 +6,12 @@ def main():
6
  raw_data = load_dataset("amazon_reviews_multi", "ja")
7
  raw_data = raw_data.rename_column("review_id", "id")
8
  raw_data = raw_data.rename_column("review_body", "text")
9
- raw_data = raw_data.rename_column("stars", "label")
10
  raw_data = raw_data.remove_columns(["product_id", "reviewer_id", "review_title", "language", "product_category"])
11
 
12
  for split, dataset in raw_data.items():
 
13
  dataset = dataset.map(lambda x: {"label_text": str(x["label"])}, num_proc=4)
 
14
  dataset.to_json(f"{split}.jsonl")
15
 
16
  if __name__ == "__main__":
 
6
  raw_data = load_dataset("amazon_reviews_multi", "ja")
7
  raw_data = raw_data.rename_column("review_id", "id")
8
  raw_data = raw_data.rename_column("review_body", "text")
 
9
  raw_data = raw_data.remove_columns(["product_id", "reviewer_id", "review_title", "language", "product_category"])
10
 
11
  for split, dataset in raw_data.items():
12
+ dataset = dataset.map(lambda x: {"label": x["stars"]-1}, num_proc=4)
13
  dataset = dataset.map(lambda x: {"label_text": str(x["label"])}, num_proc=4)
14
+ dataset = dataset.remove_columns(["stars"])
15
  dataset.to_json(f"{split}.jsonl")
16
 
17
  if __name__ == "__main__":