upload
Browse files- README.md +8 -0
- original.csv +3 -0
- prepare.py +45 -0
- test.jsonl +3 -0
- train.jsonl +3 -0
README.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Toxic Conversation
|
2 |
+
This is a version of the [Jigsaw Unintended Bias in Toxicity Classification dataset](https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/overview). It contains comments from the Civil Comments platform together with annotations if the comment is toxic or not.
|
3 |
+
|
4 |
+
This dataset just contains the first 50k training examples.
|
5 |
+
|
6 |
+
10 annotators annotated each example and, as recommended in the task page, set a comment as toxic when target >= 0.5
|
7 |
+
|
8 |
+
The dataset is inbalanced, with only about 8% of the comments marked as toxic.
|
original.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9bc510519bb010a46c343d9733f9abfb33d31127d7fc08d72237cdfcb7a982be
|
3 |
+
size 816211476
|
prepare.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from collections import Counter
|
3 |
+
import json
|
4 |
+
import random
|
5 |
+
|
6 |
+
|
7 |
+
df = pd.read_csv("original.csv")
|
8 |
+
|
9 |
+
print(df)
|
10 |
+
"""
|
11 |
+
for field in ["target", "severe_toxicity", "obscene", "identity_attack", "insult", "threat"]:
|
12 |
+
print("\n\n", field)
|
13 |
+
num_greater = 0
|
14 |
+
for val in df[field]:
|
15 |
+
if val >= 0.5:
|
16 |
+
num_greater += 1
|
17 |
+
|
18 |
+
print(num_greater, len(df[field]), f"{num_greater/len(df[field])*100:.2f}%")
|
19 |
+
"""
|
20 |
+
|
21 |
+
|
22 |
+
rows = [{'text': row['comment_text'].strip(),
|
23 |
+
'label': 1 if row['target'] >= 0.5 else 0,
|
24 |
+
'label_text': "toxic" if row['target'] >= 0.5 else "not toxic",
|
25 |
+
} for idx, row in df.iterrows()]
|
26 |
+
|
27 |
+
random.seed(42)
|
28 |
+
random.shuffle(rows)
|
29 |
+
|
30 |
+
num_test = 50000
|
31 |
+
splits = {'test': rows[0:num_test], 'train': rows[num_test:]}
|
32 |
+
|
33 |
+
print("Train:", len(splits['train']))
|
34 |
+
print("Test:", len(splits['test']))
|
35 |
+
|
36 |
+
num_labels = Counter()
|
37 |
+
|
38 |
+
for row in splits['test']:
|
39 |
+
num_labels[row['label']] += 1
|
40 |
+
print(num_labels)
|
41 |
+
|
42 |
+
for split in ['train', 'test']:
|
43 |
+
with open(f'{split}.jsonl', 'w') as fOut:
|
44 |
+
for row in splits[split]:
|
45 |
+
fOut.write(json.dumps(row)+"\n")
|
test.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b827bccd4c56e5e18ddf4c55fb410d37f661c15eb2b43aa250a933b6f4452254
|
3 |
+
size 17546214
|
train.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e92ff39a269f8ee3b6a227781a12896b90b34bfa33919f1994bbc5dc0a669a18
|
3 |
+
size 17660065
|