## 4 Data Understanding and Preparation  
### Dataset Description  
In the experiments, we used the Toxic Comment Classification Challenge (Available online: www.kaggle.com/c/jigsaw-toxic-comment-classification-challenge) competition dataset, as it presents an interesting challenge, widely used in training of the toxicity detection models. It consists of Wikipedia comments, which contain the comment (id) and textual content of the comment (comment_text feature). Each comment is marked with a specific type of toxicity. Each type of the toxicity is represented by a particular label: _toxic_, _severe_toxic_, _obscene_, _threat_, _insult_ and _identity_hate_. The comments can be labelled with multiple types of toxicity. Figure 4 depicts a sample of the training data. As we can see from the figure, toxic comments are often written using an explicit language, written in all caps, using numerous punctuation marks.  
Dataset is divided into the training and testing set. Training data consists of 159,751 samples. The models were evaluated on the independent testing set consisting of totally 153,164 records. However, to prevent the effect of the hand-labelling of the dataset, the testing set contained comments  
Figure 4: Sample of training data Toxic Comment Challenge.  
to be not included in scoring (labelled by \(-1\)). After removal of these record, testing set used for evaluation consisted of 63,978 records. Table 1 shows the number of samples in the training and test set for each class. Please note that most of the toxic comments are labelled with more than one type of toxicity. Non-toxic comments have not assigned a specific label, but are not assigned with any of the toxic labels (\"clear\" comments in the Table 1).  
The average comment consisted of 394 characters. Figure 5 depicts the number of comments depending on the length of the comment within each class. In our experiments, we worked with an average comment length of 200 characters.  
Comments in the data may belong to multiple classes (e.g., toxic comments may contain various types of toxicity). On the contrary, the initial data exploration showed, that certain comments labelled as an obscene, threat, insult, or identity hate, may not be considered as toxic (see Table 2). We decided to keep such comments in the dataset, even though they are not considered as toxic, they could be considered as anti-social from a different perspective.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Toxicity** & **Training Set** & **Testing Set** \\ \hline toxic & 15,294 & 6090 \\ severe toxic & 1595 & 367 \\ obscene & 8449 & 3691 \\ threat & 478 & 211 \\ insult & 7877 & 3427 \\ identity hate & 1405 & 712 \\ “clear” & 143,346 & 5773 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Type of toxicity occurrences in training and testing dataset.  
Figure 5: The first graph depicts the length of the comments in respective categories. The second one depicts the number of the comments belonging with multiple categories.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Category** & **Frequency** \\ \hline severe toxic AND toxic & 1595 \\ obscene AND toxic & 7926 \\ threat AND toxic & 449 \\ insult AND toxic & 7344 \\ identity hate AND toxic & 1302 \\ \hline severe toxic but NOT toxic & 0 \\ obscene but NOT toxic & 523 \\ threat but NOT toxic & 29 \\ insult but NOT toxic & 533 \\ identity hate but NOT toxic & 103 \\ \hline \hline \end{tabular}
\end{table}
Table 2: A comparison of the occurrence and frequency of individual categories with the toxic category.  
Figure 6 shows the correlation between the target variables. The highest levels of correlation can be observed between the obscene, toxic its and insult classes.