amazon_polarity / create_dataset.py
lewtun's picture
lewtun HF Staff
Fix column names
43dd535
raw
history blame contribute delete
399 Bytes
from datasets import load_dataset
def main():
id2label = {0: "negative", 1: "positive"}
raw_dset = load_dataset("amazon_polarity")
for split, dset in raw_dset.items():
dset = dset.rename_column("content", "text")
dset = dset.map(lambda x: {"label_text": id2label[x["label"]]}, num_proc=4)
dset.to_json(f"{split}.jsonl")
if __name__ == "__main__":
main()