lewtun HF staff florentgbelidji HF staff commited on
Commit
b83b208
1 Parent(s): eb2aeb7

multilabel_config (#1)

Browse files

- Changed format to have labels as columns (2b9793bd12ee8766d434598a7789cc4ef90886da)


Co-authored-by: Florent Gbelidji <florentgbelidji@users.noreply.huggingface.co>

Files changed (4) hide show
  1. create_dataset.py +14 -3
  2. test.jsonl +2 -2
  3. train.jsonl +2 -2
  4. validation.jsonl +2 -2
create_dataset.py CHANGED
@@ -1,15 +1,26 @@
1
  from datasets import load_dataset
2
 
3
 
 
 
4
  def main():
5
  raw_dset = load_dataset("go_emotions", "simplified")
6
- raw_dset = raw_dset.rename_column("labels", "label")
7
- labels = raw_dset["train"].features["label"].feature
 
 
 
 
 
 
8
 
9
  for split, dset in raw_dset.items():
10
- dset = dset.map(lambda x: {"label_text": [labels.int2str(l) for l in x["label"]]}, num_proc=4)
 
11
  dset.to_json(f"{split}.jsonl")
12
 
13
 
 
 
14
  if __name__ == "__main__":
15
  main()
 
1
  from datasets import load_dataset
2
 
3
 
4
+ # +
5
+
6
  def main():
7
  raw_dset = load_dataset("go_emotions", "simplified")
8
+ labels = raw_dset["train"].features["labels"].feature
9
+
10
+ def create_labels(row):
11
+ labels_columns = {}
12
+ for _label in labels.names:
13
+ labels_columns.setdefault(_label, 0)
14
+ labels_columns.update({labels.int2str(_l):1 for _l in row['labels']})
15
+ return labels_columns
16
 
17
  for split, dset in raw_dset.items():
18
+ dset = dset.map(lambda x: create_labels(x), num_proc=4)
19
+ dset = dset.remove_columns(["id", "labels"])
20
  dset.to_json(f"{split}.jsonl")
21
 
22
 
23
+ # -
24
+
25
  if __name__ == "__main__":
26
  main()
test.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7cd3e20dd72f27263b5a91c8be5f813ebc18d84f7843deb51801e9b57930bb39
3
- size 743871
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63c68fd56fa2470a701135a0c31dd8aff946a535efef663a7917415149e88630
3
+ size 2400101
train.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0acc140492c01f3b13d838565d107607068f2b98f33b62372b63796e4cdeb217
3
- size 5979423
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b14e8b3fd45a657f4a01267fab784db088893da29e3415fbcd2221d8dfac4198
3
+ size 19222477
validation.jsonl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0fc7a1b582a5fcf707ff088cfc3daf6e085cbc6081000888643f8eb09744f88f
3
- size 746703
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bff7228526b2d0053a50cc16e8d1b4093d46f919c7f7097387fc7b5dbaf396d1
3
+ size 2402070