Download create_dataset.py from SetFit/imdb: direct link, hf CLI and curl.
- Browser
- Download file 332 Bytes
-
https://huggingface.co/datasets/SetFit/imdb/resolve/main/create_dataset.py
- Command line
-
hf download hf://datasets/SetFit/imdb/create_dataset.py
-
curl -L -o create_dataset.py https://huggingface.co/datasets/SetFit/imdb/resolve/main/create_dataset.py
332 Bytes
| from datasets import load_dataset | |
| def main(): | |
| id2label = {0: "negative", 1: "positive", -1: "unlabeled"} | |
| imdb = load_dataset("imdb") | |
| for split, dset in imdb.items(): | |
| dset = dset.map(lambda x: {"label_text": id2label[x["label"]]}) | |
| dset.to_json(f"{split}.jsonl") | |
| if __name__ == "__main__": | |
| main() | |