Add data
Browse files- create_dataset.py +18 -0
- test.jsonl +3 -0
- train.jsonl +3 -0
create_dataset.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import Dataset
|
2 |
+
from sklearn.datasets import fetch_20newsgroups
|
3 |
+
|
4 |
+
|
5 |
+
def main():
|
6 |
+
for split in ["train", "test"]:
|
7 |
+
# Follow recommendation to strip newsgroup metadata
|
8 |
+
# https://scikit-learn.org/0.19/datasets/twenty_newsgroups.html#filtering-text-for-more-realistic-training
|
9 |
+
data = fetch_20newsgroups(subset=split, remove=("headers", "footers", "quotes"))
|
10 |
+
id2label = {idx: label for idx, label in enumerate(data["target_names"])}
|
11 |
+
d = {"text": data["data"], "label": data["target"]}
|
12 |
+
dset = Dataset.from_dict(d)
|
13 |
+
dset = dset.map(lambda x: {"label_text": id2label[x["label"]]})
|
14 |
+
dset.to_json(f"{split}.jsonl")
|
15 |
+
|
16 |
+
|
17 |
+
if __name__ == "__main__":
|
18 |
+
main()
|
test.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a0c1f20c01fa77f6b832fdb5e6218018660781e762f3e68ee3e6f279e7839bcc
|
3 |
+
size 8906768
|
train.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b696a1d6a43a306b2ea21cdf20be62c1e56a04908053f24e606707454e84a728
|
3 |
+
size 14810848
|