nreimers commited on
Commit
1916f66
1 Parent(s): ee17c14
Files changed (5) hide show
  1. README.md +1 -0
  2. enron_spam_data.csv +3 -0
  3. prepare.py +38 -0
  4. test.jsonl +3 -0
  5. train.jsonl +3 -0
README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ This is a version of the [Enron Spam Email Dataset](https://github.com/MWiechmann/enron_spam_data), containing emails (subject + message) and a label whether it is spam or ham.
enron_spam_data.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:009c86359b5bd6ec142a9b9ca85075ec864fd8c7c1c378c9a430e9427d0f7d57
3
+ size 51690056
prepare.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ from collections import Counter
3
+ import json
4
+ import random
5
+
6
+ df = pd.read_csv("enron_spam_data.csv")
7
+ df.fillna('', inplace=True)
8
+ print(df)
9
+ label2id = {'ham': 0, 'spam': 1}
10
+
11
+ rows = [{'message_id': row['Message ID'],
12
+ 'text': (row['Subject']+" "+row['Message']).strip(),
13
+ 'label': label2id[row['Spam/Ham']],
14
+ 'label_text': row['Spam/Ham'],
15
+ 'subject': row['Subject'],
16
+ 'message': row['Message'],
17
+ 'date': row['Date']
18
+ } for idx, row in df.iterrows()]
19
+
20
+ random.seed(42)
21
+ random.shuffle(rows)
22
+
23
+ num_test = 2000
24
+ splits = {'test': rows[0:num_test], 'train': rows[num_test:]}
25
+
26
+ print("Train:", len(splits['train']))
27
+ print("Test:", len(splits['test']))
28
+
29
+ num_spam = Counter()
30
+
31
+ for row in splits['test']:
32
+ num_spam[row['label']] += 1
33
+ print(num_spam)
34
+
35
+ for split in ['train', 'test']:
36
+ with open(f'{split}.jsonl', 'w') as fOut:
37
+ for row in splits[split]:
38
+ 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:f07a4cca7bfc1d845d4ff59650e69a0ad31d9b5c0409ddad088219f7fc32bb52
3
+ size 6273613
train.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b846cf15bcad7676c37ea3535622e39e6bff5c9c004f634513e4f9c2951e5f02
3
+ size 101069043