Using data science to prevent cyberbullying on social media
Technological developments have provided society with smart devices such as phones or tablets that provide access to the web anywhere and anytime. Parallel with the technological development the rise of social media occurred. According to the website of Statista, since 2010 the number of social media users has increased from 1 billion to 2.6 billion and is expected to reach 3 billion by the end of 2021. The same source claims that some of the most popular social media are Facebook, Twitter and Instagram. Young people spend a large part of their time in social media, posting and commenting on photos, exchanging videos and chatting. Part of these interactions contains aggressive behavior referred to as cyberbullying. A general deﬁnition of cyberbullying is that people use electronic devices to intimidate, threaten or humiliate another web user.
This violent behavior can humiliate the user with disastrous effects for the emotional state of the victim. More speciﬁcally, for young victims the consequences of cyberbullying vary from low academic performance to suicidal ideation (Nikolaou 2017). In order to protect users from cyberbullying, some researchers focus on the development of machine learning algorithms that will detect text messages characterized by negative and humiliating content. Detection of cyberbullying is seen as one of the initial steps in order to prevent cyberbullying.
Machine learning models that are based on word embeddings can be used for detection of cyberbullying in social media. One of these models are word embeddings that have been used successfully in previous work. Word embeddings have been applied successfully for, i) text classiﬁcation (Mironczuk and Protasiewicz 2018), ii) answering knowledge based questions (Yang et al. 2015), iii) sentiment analysis (Le and Mikolov 2014), iv) information retrieval (Grbovic et al. 2015) and v) gender classiﬁcation (Bhagvati 2018). Sentiment analysis is one of the most similar task to the cyberbullying detection task. More particular, sentiment analysis is a particular case of text classiﬁcation problem, in which part of a text is marked either with a positive or negative label (binary classiﬁcation problem).
The research question of the current work is to investigate how classiﬁers based exclusively on word embeddings compare with other techniques used for detection of cyberbullying in social media. According to previous work (Melamud et al. 2016) word vectors with higher dimensionality are characterized by higher quality based on different evaluation metrics (word similarity, word analogy etc). Due to the above observation, hypothesis is that classiﬁers based on word vectors with high dimensionality will perform better on cyberbullying detection compared to classiﬁers based on word vectors with lower dimensionality.
Training of word embeddings
In order to get the word embeddings, unsupervised training took place using the library of Gensim in Python. Since word embeddings will be used for cyberbullying detection in social media, it was decided to train the word embeddings with a large corpus from Twitter. The word embeddings trained with this corpus are expected to capture both syntactic and semantic information suitable for classiﬁcation in social media (Li et al. 2017a). The corpus used for training was part of the Edinburgh Twitter Corpus consisting of about 38 millions of tweets and collected between November 2009 and February 2010. Pre-processing of the Twitter data consisted of removing special characters, symbols and numbers, and each tweet was split on sentence-level.
In total three different models were trained, namely word2vec-Skip-Gram (word2vecSkipGram), word2vec-Continous Bag of Words (word2vecCBOW) and fastText-Continous Bag of Words (fastTextCBOW). In order to make a comparison, pre-trained vectors obtained by researchers of Stanford University were also evaluated and used for classiﬁcation. These vectors were obtained from unsupervised training on Twitter data using the Glove algorithm.
The effect of the dimension of the vectors was tested by evaluating and applying vectors with different size. Vectors with dimensions of 25, 200 and 400 were trained. For the model of word2vecSkipGram word embeddings of dimensions of 1200 were also trained in order to evaluate their feature representation for cyberbullying detection. For the training of the word vectors, two parameters were modiﬁed. The window size was set to 5 since this is a common value for training and getting the word vectors. The parameter of ’minimum count’, which determines if a word will get a vector or not by the times it is appeared in the corpus, was set to 5. This ensures that even relatively rare words will get a vector and will be represented during the modeling for cyberbullying detection.
Description of the raw data sets used for modeling
To train cyberbullying classiﬁers we used different data sources. The majority of the data is “innocent”, with a few instances to be annotated as instances that contain cyberbullying content. An overview of the properties of the data is presented in Table 1.
Table 1: Instances and majority baseline for data used for training classiﬁers for cyberbullying detection
A ﬁrst group of dataset consists of chat transcripts scraped from the website of MySpace. The conversations are thread-style forums, where a general topic is included in the creation of a thread. A single post can contain multiple sentences. A second group consists of data collected from the social networking site AskFm. These data consist of short question-answer pairs published on a user’s proﬁle. Data were retrieved in April and October 2013. Annotation was done by experienced linguists. The third group was collected from the platform Formspring, which is a question and answer formatted website. Finally, we used text messages that have been posted in Twitter. Data were collected between October and December 2012. Annotation was conducted by three annotators. A message was tagged as online harassment if there was a consensus between at least two of the three annotators.
Modeling for cyberbullying detection
Raw data were pre-processed in a similar way as the Edinburgh Twitter Corpus. Two different model conﬁgurations were evaluated in the present study. The ﬁrst model replaces each word of a sentence with the corresponding vectors and then sum-up all the vectors (summation model). By executing this the features space of the classiﬁers are vectors of the same size. In case a word was not found in the vocabulary of the trained word embedding model, a vector with zero elements was added. An alternative representation was applied which concatenates the vector of words for each sentence (concatenation model). In order for each instance (sentence or paragraph) to have the same size, only the ﬁrst ten to twenty words were considered. In case the sentence contained less than ten to twenty words, then the vector was padded with zeros. Thus for a model with 10 words and vector dimension of 400, the sentence is represented by a vector of 4000. Principal component analysis was performed to reduce space complexity and training time.
The data were randomly split in training and evaluation data in portions of 80% and 20%. The vectors were normalized before feeding the classifiers. A non-linear SVM was used for training the model and ﬁt the data. The C and gamma parameters of the SVM were tuned in order to maximize F1 using scikit-learn. Additionally, the accuracy, recall and precision are reported. For clariﬁcation, the ﬂow process of this study is given in Figure 1. Pre-processing of the raw data is the ﬁrst step of the work ﬂow. Then training to get the word embeddings and implementation of external word embeddings follows. The third step is evaluation of the word embeddings with word similarities. Results about evaluation will be provided in a future article. The ﬁnal step is the cyberbullying detection with different model representations and the corresponding classiﬁers.
Figure 1: Flow chart of the current study
As already mentioned two different model representations are tested in this study (summation and concatenation). For the concatenation model, we use PCA for the AskFm and Formspring data, due to the high number of instances. By applying PCA, the number of features reduces to 400 (see Figure 2) with a total explained variance of 48%.
Figure 2: Cumulative variance as a function of the number of components
The concatenation model is inferior to the summation model. For this reason, results presented in this section refer to the summation model. A comparison between cyberbullying detection results obtained in previous works and in the current study for the platform of MySpace is shown in Table 2. High values of accuracy (above 95.94%) and F1 score (above 91.11%) have been achieved for all the different embedding models. The best model is the word2vecCBOW with vector dimension of 400. For this model we achieve an accuracy of 98.81%, F1 score of 96.92% and precision score of 97.5%.
Table 2: Models evaluation for summation representation for MySpace Data: where Ref. is Reference, Dim. is Dimension, Param. is Parameters, Acc. is Accuracy, Rec. is Recall and Prec. is Precision
Models based exclusively on word embeddings were used for cyberbullying detection in data of AskFm, Formspring and Twitter. An overview of the classiﬁcation metrics that have been obtained in previous and current work is presented in Table 3.
Table 3: Metrics comparison on data sets from different social media using the summation representation: Where Ref. is Reference, Dim. is Dimension, Acc. is Accuracy, ReC. is Recall and Prec. is Precision
The best results are obtained with word embeddings with high dimensionality. In general, the model that uses word embeddings outperforms previous models in terms of precision. This means that the number of instances that do not contain cyberbullying content, and are predicted as guilty is very low. For AskFm data, a similar F1 score as with previous study is obtained. The model based on dimension word embeddings of 1200 is very similar to the model with a dimensionality of 400. Using word embeddings for the Formspring and Twitter data, lower metrics are achieved in terms of recall and F1 score. The accuracy reported by Reynolds, Kontostathis, and Edwards (2011) for balanced data of Formspring was 81.70%. This accuracy cannot be compared with the accuracy achieved in the current work, since it corresponds to unbalanced data.
The research question of this study is how classifiers based on word embeddings perform for cyberbullying detection compared to other methods. We implemented word embeddings for cyberbullying detection in different social media platforms. Promising results are obtained for all the platforms when vectors of each sentence are summed-up. For the social media of MySpace, higher classiﬁcation metrics are obtained in the current work compared to what has been published before.
For the data of AskFm, Formspring and Twitter word embeddings models provide lower metrics in terms of accuracy, recall and F1 in comparison with previous research. For data containing short sentences with symbols and emoji’s (AskFm, Formspring, Twitter), classiﬁcation is a more difﬁcult task using word embeddings. As a result, lower metrics than the metrics for MySpace data are achieved. Word embedding models developed in this study, are characterized by higher precision compared to previous research. We conclude that the performance of models based on word embeddings, does not generalize and depends on the applied data.
The hypothesis of this study is that word embedding models with high dimensionality will perform better compared to models with vectors of lower dimension. The performance of the model which uses word embeddings improves as the dimensionality of the model increases. Looking at the evaluation for the MySpace platform (Table 2), we observe that the highest evaluation metrics are consistently obtained with the highest vector dimensionalities (above 200). For other social media platforms, vectors with high dimensionality provide the best classiﬁcation metrics (see Table 3). We conclude that an increasing dimensionality of the vectors, relates to a better performance of the word embedding model on cyberbullying detection. This confirms the hypothesis stated in this study.
Bayzick, Jennifer, April Kontostathis, and Lynne Edwards. 2011. Detecting the presence of cyberbullying using computer software. In3rd Annual ACM Web ScienceConference (WebSci ‘11), pages 1–2.
Bhagvati, Ritesh Chakravarthy. 2018. Word representations for gender classification using deep learning. Procedia Computer Science, 132:614 – 622. International Conference on Computational Intelligence and Data Science.
- Bretschneider, Uwe, Thomas Wöhner, and Ralf Peters. 2014. Detecting online harassment in social networks.
- Grbovic, Mihajlo, Nemanja Djuric, VladanRadosavljevic, Fabrizio Silvestri, and Narayan Bhamidipati. 2015. Context- and content-aware embeddings for query rewriting in sponsored search. In SIGIR.
- Le, Quoc V. and Tomas Mikolov. 2014. Distributed representations of sentences and documents. CoRR, abs/1405.4053.
- Li, Quanzhi, Sameena Shah, Xiaomo Liu, andArmineh Nourbakhsh. 2017a. Data sets:Word embeddings learned from tweets and general data. CoRR, abs/1708.03994.
- Melamud, Oren, David McClosky, Siddharth Patwardhan, and Mohit Bansal. 2016. The role of context types and dimensionality in learning word embeddings. arXiv preprintarXiv:1601.00893.
- Mironczuk, Marcin Michal and JaroslawProtasiewicz. 2018. A recent overview of the state-of-the-art elements of text classification. Expert Systems withApplications, 106:36 – 54.
- Nahar, Vinita, Sanad Al-Maskari, Xue Li, andChaoyi Pang. 2014. Semi-supervised learning for cyberbullying detection in social networks. In Australasian Database Conference, pages 160–171, Springer.
- Nikolaou, Dimitrios. 2017. Does cyberbullying impact youth suicidal behaviors? Journal of health economics, 56:30–46.
- Reynolds, Kelly, April Kontostathis, and Lynne Edwards. 2011. Using machine learning to detect cyberbullying. In Machine learning and applications and workshops (ICMLA), 2011 10th International Conference on, volume 2, pages 241–244,IEEE.
- Squicciarini, A, S Rajtmajer, Y Liu, and Christopher Griffin. 2015. Identification and characterization of cyberbullying dynamics in an online social network. In Advances in Social Networks Analysis and Mining (ASONAM), 2015 IEEE/ACM International Conference on, pages 280–285,IEEE.
- Van Hee, Cynthia, Gilles Jacobs, ChrisEmmery, Bart Desmet, Els Lefever, BenVerhoeven, Guy De Pauw, Walter Daelemans, and Véronique Hoste. 2018.Automatic detection of cyberbullying in social media text.arXiv preprintarXiv:1801.05617.
- Van Hee, Cynthia, Els Lefever, BenVerhoeven, Julie Mennes, Bart Desmet,Guy De Pauw, Walter Daelemans, and Véronique Hoste. 2015. Detection and fine-grained classification of cyberbullying events. In International Conference Recent Advances in Natural Language Processing(RANLP), pages 672–680.
- Yang, Min-Chul, Do-Gil Lee, So-Young Park,and Hae-Chang Rim. 2015.Knowledge-based question answering using the semantic embedding space.Expert Systems with Applications,42(23):9086 – 9104.
- Yin, Dawei, Zhenzhen Xue, Liangjie Hong,Brian D Davison, April Kontostathis, and Lynne Edwards. 2009. Detection of harassment on web 2.0.Proceedings of the Content Analysis in the WEB, 2:1–7.
- Zhao, Rui, Anna Zhou, and Kezhi Mao. 2016.Automatic detection of cyberbullying on social networks based on bullying features. In Proceedings of the 17th international conference on distributed computing and networking, page 43, ACM.