-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEDA.py
46 lines (30 loc) · 791 Bytes
/
EDA.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from src import *
import matplotlib.pyplot as plt
import seaborn as sns
PATH = 'dataset/spam-ham v2.csv'
df = spam_dataframe(PATH, True, None)
print(df.info())
print(df.value_counts('is_spam'))
##
# class distribution
sns.countplot(data=df, x='is_spam')
plt.show()
##
##
# sequence length distribution
from transformers import RobertaTokenizer
from torch.utils.data import DataLoader
CHECKPOINTS = 'roberta-base'
tokenizer = RobertaTokenizer.from_pretrained(CHECKPOINTS)
dataset = Spam_Dataset(df)
collator = Spam_Collator(tokenizer, None)
loader = DataLoader(dataset, collate_fn=collator, batch_size=1)
##
seq_len = []
for i in loader:
seq_len.append(i[0]['input_ids'].shape[-1])
seq_len = pd.Series(seq_len)
print(seq_len.describe())
sns.boxplot(seq_len)
plt.show()
##