Datasets:
File size: 558 Bytes
570a98a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from ast import literal_eval
from datasets import Dataset, load_dataset
pm = load_dataset(
"owaiskha9654/PubMed_MultiLabel_Text_Classification_Dataset_MeSH", split="train"
)
records = []
for t, lab in zip(pm["abstractText"], pm["meshMajor"]):
try:
labels = literal_eval(lab)
labels = labels[:2]
records.append({"text": t, "label": labels})
except Exception:
print("Couldn't add entry:", lab)
ds = Dataset.from_list(records)
ds = ds.train_test_split(test_size=0.2, seed=42)
ds.push_to_hub("kardosdrur/pubmed")
|