Commit
·
e5e191d
1
Parent(s):
3953bb4
Update parquet files
Browse files
README.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 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 |
-
10 annotators annotated each example and, as recommended in the task page, set a comment as toxic when target >= 0.5
|
| 5 |
-
|
| 6 |
-
The dataset is inbalanced, with only about 8% of the comments marked as toxic.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test.jsonl → SetFit--toxic_conversations/json-test.parquet
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:134128c2c7314bb9b9db47c16115fc210455d8aa4caec0f221af7c95a51c936b
|
| 3 |
+
size 10475980
|
train.jsonl → SetFit--toxic_conversations/json-train-00000-of-00002.parquet
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7b13901520d023cc7b7da2d9b5c1c0946a2d214e46b6781afaa276ae8895ea2b
|
| 3 |
+
size 331694934
|
original.csv → SetFit--toxic_conversations/json-train-00001-of-00002.parquet
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e3f6ebbb682e0e51bd28e11d31a66af5fe5169d5b2a5e32bd1e164eab83e223d
|
| 3 |
+
size 36625745
|
prepare.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|