Classification Model for Bullying Posts Detection

*K. Nalini and L. Jabasheela*

### **Abstract**

Nowadays, many research tasks are concentrating on Social Media for Analyzing Sentiments and Opinions, Political Issues, Marketing Strategies and many more. Several text mining structures have been designed for different applications. Harassing is a category of claiming social turmoil in different structures and conduct toward a singular or group, to damage others. Investigation outcomes demonstrated that 7 young people out of 10 become the casualty of cyber bullying. Throughout the world, many prominent cases are existing due to the bad communications over the Web. So there could be suitable solutions for this problem and there is a need to eradicate the lacking in existing strategies in dealing problems with cyber bullying incidents. A prominent aim is to design a scheme to alert the people those who are using social networks and also to prevent them from bullying environments. Tweet corpus carries the messages in the text as well as it has ID, time, and so forth. The messages are imparted in informal form and furthermore, there is variety in the dialect. So, there is a requirement to operate a progression of filtration to handle the raw tweets before feature extraction and frequency extraction. The idea is to regard each tweet as a limited blend over a basic arrangement of topics, each of which is described by dissemination over words, and after that analyze tweets through such topic dispersions. Naturally, bullying topics might be related to higher probabilities for bullying words. An arrangement of training tweets with both bullying and non-bullying texts are required to take in a model that can derive topic distributions from tweets. Topic modeling is used to get lexical collocation designs in the irreverent content and create significant topics for a model.

**Keywords:** cyberbullying, Twitter, LDA, SVM, TF-IDF

#### **1. Introduction**

The proposed methodology is a dual compound method. It utilizes the arrangement of "bullying" or "non-bullying" class and also it utilizes link analysis to locate the most dynamic users as predators and victims. Each step can be explained in detail as follows. The feature selection is an essential phase in denoting data within component space to the categorizers. Mostly the data available from social network are noisy. So, there is a need to apply pre-processing techniques in order to obtain the research data with better quality followed by successive systematic steps; Moreover, sparsity in feature space increases with the count of documents. Nevertheless, the following types of features generated through the B-LDA topic model

and weighted B-TF-IDF scheme. In the initial step, semantic highlights are related for locating harassing, abusive and offending posts. In pestering discovery the presence of pronouns in the nuisance post was represented. Essentially in this work, three sorts of capabilities are utilized. They are depicted as follows: (i) all second individual pronouns "you," "yourself," and so forth are considered one term; (ii) all other outstanding pronouns "he," "she," and so on., are viewed together as another element; (iii) foul words such as "fr\*\*k," "shit," "moronic," and so forth., which make the post merciless are assembled in another arrangement of highlights. The new harassing words lexicon was made in view of the accompanying essential sites like *noswearing.com and urban dictionary*. The primary rationale behind consolidating these features is that it will boost the viability of the classification of tormenting posts. The classification outcomes are revealed in the experiments.

executed by a bag of word method with Naïve Bayes classifier and then the Boolean system is applied to classify the content. Javier et al. [7] have displayed automatic strategies for identifying erotic plundering in Chat rooms. They have effectively demonstrated that a learning-based technique is an attainable method to approach this issue and have proposed novel sets of highlights to determine the classification of chat partakers as exploiters or non-exploiters. They exhibited that the arrangements of features used and the comparative weighting of the disarrangement expenditures in the SVMs are two fundamental factors that ought to be considered

Huang et al. [8] proposed normal text investigation using social network characteristics to classify harassing in Twitter and also considered the social connection between clients would betterment outcome for classification. Zhao et al. [9] applied a collection of features known as EBoW (Natural Language Processing method), containing a bag of words structure connected with Latent Semantic analysis and word embeddings by computing word vectors. They also used SVM to classify the

Chen et al. [10] researched existing content mining techniques in recognizing harassing texts for ensuring adolescent online safety. In particular, they proposed the Lexical Syntactical Feature (LSF) way to deal with hostile contents on the internet and further foresee a client's potentiality to convey hostile contents. Their investigation has many commitments. To begin with, they essentially conceptualize the idea of online hostile contents and further recognize the contribution of pejoratives/obscenities and profanities in deciding offensive substance, and present hand creating syntactic standards in finding verbally abusing provocation. Second, they enhanced customary Machine-Learning strategies by not just utilizing lexical features to identify hostile dialect, yet in addition style feature, structure features, and content-specific features to better foresee a client's possibility to convey hostile content in social media. Investigation result demonstrates that the LSF Sentence offensiveness forecast and client offensiveness estimate algorithm beat, customary learning-based methodologies in turns of precision, recall, and F-score. The LSF endures casual and incorrect spelling contents and it can possibly adjust to any

data collection in Twitter which contains keywords like bully or bullying.

**3. The Bully-latent Dirichlet allocation (B-LDA): model design**

LDA is an outstanding method of Bayesian multinomial mixture model in text analysis based on its ability to assemble, elucidate and semantically cogent topics. It uses the Dirichlet distribution to model the distribution of the topics for each and every one document. In LDA, each word is measured from a multinomial distribution over words particular to this topic. Since LDA is extremely modular and hierarchical, consequently, it can simply be broadened. Various expansions to basic LDA model have been recommended to incorporate document metadata. The easy process of integrating the metadata in generative topic models is to create both the words and the metadata concurrently specified unseen topic variables. The Author-Topic (AT) model resembles Bayesian network, in which every authors' attractions are modeled with a combination of topics [11]. In this model an arrangement of authors, advertisements are watched and looked over from different documents depends on their topics. To create each word, an author x is picked at identical from this set, then a topic z is chosen from a topic distribution θ<sup>x</sup> that is particular to the author, and after that, a word w is created by testing from a topic-particular

to upgrade execution.

*Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

forms of English written word styles.

multinomial distribution ϕz.

**151**

## **2. Review of literature**

Rahat et al. [1] presented a multi-stage cyber bullying detection results that radically decreases the classification period and give warning signals. The system is greatly scalable without forfeiting precision and highly approachable in raising signals. It also contained an active priority scheduler and a rising classification procedure by applying Vine data sets. The performance outcomes demonstrate that the model enhances the scalability of digital harassing discovery contrasted to nonpriority model and also explained that the system could fully check Vine-scale networks. The results depict that this digital harassing detection is considerably more measurable and receptive than the present modern technology. Zhong et al. [2] proposed an investigation to find out cyberbullying in Instagram utilizing the improvement of early-warning methods to detect offensive images.

The research operated by obtaining a huge volume of pictures in the Instagram image sharing process along with messages. They studied new features of the topics acquired from the picture portrayal and trained using neural network technology, added with images and texts. The results got the potential objectives for harassing on the characterization of texts and images. Sherly [3] proposed research using supervised feature selection to select the characteristics from the tweets by the ranking method. Then extreme learning machine (ELM) classifier is applied to execute the cyberbullying detection and enhance the precision and reduce the performance period. The performance investigation of the SFS-ELM model observed that the accuracy is improved by 13% and executed using MATLAB. Micheline et al. [4] accomplished a study by using an unsupervised methodology to identify harassing messages in social networks, utilizing Growing Hierarchical Self Organizing Map. The research contains various features to find semantic and syntactic interactions of regular cyber tormentors. They conducted various trials on FormSpring, Twitter and YouTube networks by collecting real time datasets. The outcomes of the research show that the model attains the significant performance and also promotes permanent watching applications to alleviate the huge issues of harassing. Suchini et al. [5] applied a text classification model to categorize the text as insulting or not. Feature selection is performed using Chi-square test and then classification algorithms are utilized for segregating comments as insulting or noninsulting words. Various algorithms like SVM, Naive Bayes, Logistic Regression, Random Forest are applied and out of all algorithms, SVM gave better results.

Krishna et al. [6] proposed a model deployed for detecting abusive text and images in the social network. This automated system could find the offensive content in messages using the combination of a bag of visual word method, local binary pattern and SVM classifier. The offensive detection in the text messages are

#### *Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

and weighted B-TF-IDF scheme. In the initial step, semantic highlights are related for locating harassing, abusive and offending posts. In pestering discovery the presence of pronouns in the nuisance post was represented. Essentially in this work, three sorts of capabilities are utilized. They are depicted as follows: (i) all second individual pronouns "you," "yourself," and so forth are considered one term; (ii) all other outstanding pronouns "he," "she," and so on., are viewed together as another element; (iii) foul words such as "fr\*\*k," "shit," "moronic," and so forth., which make the post merciless are assembled in another arrangement of highlights. The new harassing words lexicon was made in view of the accompanying essential sites like *noswearing.com and urban dictionary*. The primary rationale behind consolidating these features is that it will boost the viability of the classification of tormenting

Rahat et al. [1] presented a multi-stage cyber bullying detection results that radically decreases the classification period and give warning signals. The system is greatly scalable without forfeiting precision and highly approachable in raising signals. It also contained an active priority scheduler and a rising classification procedure by applying Vine data sets. The performance outcomes demonstrate that the model enhances the scalability of digital harassing discovery contrasted to nonpriority model and also explained that the system could fully check Vine-scale networks. The results depict that this digital harassing detection is considerably more measurable and receptive than the present modern technology. Zhong et al. [2] proposed an investigation to find out cyberbullying in Instagram utilizing the

The research operated by obtaining a huge volume of pictures in the Instagram image sharing process along with messages. They studied new features of the topics acquired from the picture portrayal and trained using neural network technology, added with images and texts. The results got the potential objectives for harassing on the characterization of texts and images. Sherly [3] proposed research using supervised feature selection to select the characteristics from the tweets by the ranking method. Then extreme learning machine (ELM) classifier is applied to execute the cyberbullying detection and enhance the precision and reduce the performance period. The performance investigation of the SFS-ELM model observed that the accuracy is improved by 13% and executed using MATLAB. Micheline et al. [4] accomplished a study by using an unsupervised methodology to identify harassing messages in social networks, utilizing Growing Hierarchical Self Organizing Map. The research contains various features to find semantic and syntactic interactions of regular cyber tormentors. They conducted various trials on FormSpring, Twitter and YouTube networks by collecting real time datasets. The outcomes of the research show that the model attains the significant performance and also promotes permanent watching applications to alleviate the huge issues of harassing. Suchini et al. [5] applied a text classification model to categorize the text as insulting or not. Feature selection is performed using Chi-square test and then classification algorithms are utilized for segregating comments as insulting or noninsulting words. Various algorithms like SVM, Naive Bayes, Logistic Regression, Random Forest are applied and out of all algorithms, SVM gave better results. Krishna et al. [6] proposed a model deployed for detecting abusive text and images in the social network. This automated system could find the offensive content in messages using the combination of a bag of visual word method, local binary pattern and SVM classifier. The offensive detection in the text messages are

posts. The classification outcomes are revealed in the experiments.

improvement of early-warning methods to detect offensive images.

**2. Review of literature**

*Cyberspace*

**150**

executed by a bag of word method with Naïve Bayes classifier and then the Boolean system is applied to classify the content. Javier et al. [7] have displayed automatic strategies for identifying erotic plundering in Chat rooms. They have effectively demonstrated that a learning-based technique is an attainable method to approach this issue and have proposed novel sets of highlights to determine the classification of chat partakers as exploiters or non-exploiters. They exhibited that the arrangements of features used and the comparative weighting of the disarrangement expenditures in the SVMs are two fundamental factors that ought to be considered to upgrade execution.

Huang et al. [8] proposed normal text investigation using social network characteristics to classify harassing in Twitter and also considered the social connection between clients would betterment outcome for classification. Zhao et al. [9] applied a collection of features known as EBoW (Natural Language Processing method), containing a bag of words structure connected with Latent Semantic analysis and word embeddings by computing word vectors. They also used SVM to classify the data collection in Twitter which contains keywords like bully or bullying.

Chen et al. [10] researched existing content mining techniques in recognizing harassing texts for ensuring adolescent online safety. In particular, they proposed the Lexical Syntactical Feature (LSF) way to deal with hostile contents on the internet and further foresee a client's potentiality to convey hostile contents. Their investigation has many commitments. To begin with, they essentially conceptualize the idea of online hostile contents and further recognize the contribution of pejoratives/obscenities and profanities in deciding offensive substance, and present hand creating syntactic standards in finding verbally abusing provocation. Second, they enhanced customary Machine-Learning strategies by not just utilizing lexical features to identify hostile dialect, yet in addition style feature, structure features, and content-specific features to better foresee a client's possibility to convey hostile content in social media. Investigation result demonstrates that the LSF Sentence offensiveness forecast and client offensiveness estimate algorithm beat, customary learning-based methodologies in turns of precision, recall, and F-score. The LSF endures casual and incorrect spelling contents and it can possibly adjust to any forms of English written word styles.

## **3. The Bully-latent Dirichlet allocation (B-LDA): model design**

LDA is an outstanding method of Bayesian multinomial mixture model in text analysis based on its ability to assemble, elucidate and semantically cogent topics. It uses the Dirichlet distribution to model the distribution of the topics for each and every one document. In LDA, each word is measured from a multinomial distribution over words particular to this topic. Since LDA is extremely modular and hierarchical, consequently, it can simply be broadened. Various expansions to basic LDA model have been recommended to incorporate document metadata. The easy process of integrating the metadata in generative topic models is to create both the words and the metadata concurrently specified unseen topic variables. The Author-Topic (AT) model resembles Bayesian network, in which every authors' attractions are modeled with a combination of topics [11]. In this model an arrangement of authors, advertisements are watched and looked over from different documents depends on their topics. To create each word, an author x is picked at identical from this set, then a topic z is chosen from a topic distribution θ<sup>x</sup> that is particular to the author, and after that, a word w is created by testing from a topic-particular multinomial distribution ϕz.

The proposed Bully-LDA (B-LDA) model is used for identifying bullying words used by authors. This model captures bullying-topics which are used in social networks like Twitter. In Twitter, one person sends tweets to many followers. Here in this model, the sender is considered as Predator, when he/she sends bullying words to their followers. The followers are represented as Victims. The B-LDA model is a generative process model and also encapsulates topics and the communication networks of Predators and Victims by conditioning the multinomial distribution over bullying topics distinctly on both the Predator and a Victim of a bullying message. Unlike other models, B-LDA model takes into concern both predator and victims distinctly. The motive of the predator is also considered in addition to this representation. Each motive is associated with a set of topics, and these topics may overlap. For example, the categories of motive can be racist, sexual, outrage, irrelevant. The sexual motive of predator contains the topics of crude, implicit/ambiguous language or an indecent proposal. The Racist category contains more abusive matters such as homophobia, extremism, slurs, etc. The outrage is a category, which specifies reactions that express contempt. The messages that do not contain any form of offensive language are considered to be irrelevant. Each predator has a multinomial distribution over motives. Thus, B-LDA model is a clustering model, in which appearances of topics are the underlying data, and sets of correlated topics are together gathered as clusters that denote motive. Predators and Victims are mapped to motive assignments, and then a topic is selected based on these motives. The intention of each and every predator has a multinomial distribution on topics, and every topic has a multinomial distribution on words. First, the motive assignments can be made separately for each word in a document. This model represents that someone can change motive during the exchange of the messages.

distribution is specific to the predator-motive(x). At last, the word w is produced

2. for each predator and victim pair (x,y) with x = 1, … .,A and y = 1, … .,A

In this model for a particular message d, given the hyper parameters α, β, and γ, the predator pd, and set of victims vd, the connected dispersion of an author blend θ, a motive blend ψ, a topic blend ϕ, a set of Nd victims yd, and a set of Nd predator

*p ydn* ð Þ j*vd p xdn* ð Þ j*pd p zdn* ð Þ j*θxdn p wdn* ð Þ j*ϕzdn*

*p ydn* ð Þ j*vd p xdn* ð Þ j*pd p zdn* ð Þ j*θxdn p wdn* ð Þ j*ϕzdn dψdϕdθ*

*p wd* ð Þ j*α*, *β*, *γ*, *pd*, *vd* (3)

(1)

(2)

motives xd, a set of Nd topics zd and a set of Nd words wd is assigned by,

Integrating over γ, θ and ϕ and summing over yd, xd, and zd, the marginal

Then the product of the marginal probabilities of single documents, and the

*D*

*d*¼1

The assumption on models in the LDA family cannot be carried out correctly. Three standard approximations have been occupied to acquire practical results:

*p D*<sup>ð</sup> <sup>j</sup>*α*, *<sup>β</sup>*, *<sup>γ</sup>*, *<sup>p</sup>*, *<sup>v</sup>*Þ ¼ <sup>Y</sup>

¼ *p*ð Þ *ψ*j*γ p*ð Þ *θ*j*α p*ð Þ *ϕ*j*β*

by sampling from a topic-meticulous multinomial distribution ϕz. **Figure 1** is a schematic diagram of the B-LDA model. The generative procedure of this strategy is as follows:

1. for every motive m with m = 1, … ..M, choose ψ<sup>m</sup> �Dir(γ)

3. for each topic t with t = 1, … ..T, choose ϕ<sup>t</sup> � Dir(β)

b. observe predator pd and the victims vd

i. choose topic zdn � θzd

*p*ð Þ *θ*, *ϕ*, *ψ*, *yd*, *xd*, *zd*, *wd*j*α*, *β*, *γ*, *pd*, *vd*

<sup>¼</sup> <sup>Y</sup> *Nd*

distribution of a document is calculated as follows:

*p wd* <sup>ð</sup> <sup>j</sup>*α*, *<sup>β</sup>*, *<sup>γ</sup>*, *pd*, *vd*Þ ¼ ððð *<sup>p</sup>*ð Þ *<sup>ψ</sup>*j*<sup>γ</sup> <sup>p</sup>*ð Þ *<sup>θ</sup>*j*<sup>α</sup> <sup>p</sup>*ð Þ *<sup>ϕ</sup>*j*<sup>β</sup>*

Y *Nd*

X *ydn*

X *xdn*

**3.1 Monte Carlo Gibbs sampling**

X *zdn*

probability of a corpus is computed as,

*n*¼1

**153**

*n*¼1

ii. choose word wdn � ϕzdn

choose θx,y � Dir (α)

*Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

a. observe motive md

c. for each word w in d

4. for each message d

Author-Topic (AT) [11] model has been extended by incorporating a new set of variables like authors as Predators and Victims, the motivation of an author. In this generative process for each message, a Predator, pd and a set of Victims, vd are observed. To generate each word, a victim y is chosen at uniform from vd, and then a motive x for the Predator is chosen from multinomial motive distribution *ψpd*. Next a topic z is selected from a multinomial topic distribution θx, in which the

**Figure 1.** *Graphical model for B-LDA.*

#### *Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

distribution is specific to the predator-motive(x). At last, the word w is produced by sampling from a topic-meticulous multinomial distribution ϕz.

**Figure 1** is a schematic diagram of the B-LDA model. The generative procedure of this strategy is as follows:


The proposed Bully-LDA (B-LDA) model is used for identifying bullying words

Author-Topic (AT) [11] model has been extended by incorporating a new set of variables like authors as Predators and Victims, the motivation of an author. In this generative process for each message, a Predator, pd and a set of Victims, vd are observed. To generate each word, a victim y is chosen at uniform from vd, and then a motive x for the Predator is chosen from multinomial motive distribution *ψpd*. Next a topic z is selected from a multinomial topic distribution θx, in which the

used by authors. This model captures bullying-topics which are used in social networks like Twitter. In Twitter, one person sends tweets to many followers. Here in this model, the sender is considered as Predator, when he/she sends bullying words to their followers. The followers are represented as Victims. The B-LDA model is a generative process model and also encapsulates topics and the communication networks of Predators and Victims by conditioning the multinomial distribution over bullying topics distinctly on both the Predator and a Victim of a bullying message. Unlike other models, B-LDA model takes into concern both predator and victims distinctly. The motive of the predator is also considered in addition to this representation. Each motive is associated with a set of topics, and these topics may overlap. For example, the categories of motive can be racist, sexual, outrage, irrelevant. The sexual motive of predator contains the topics of crude, implicit/ambiguous language or an indecent proposal. The Racist category contains more abusive matters such as homophobia, extremism, slurs, etc. The outrage is a category, which specifies reactions that express contempt. The messages that do not contain any form of offensive language are considered to be irrelevant. Each predator has a multinomial distribution over motives. Thus, B-LDA model is a clustering model, in which appearances of topics are the underlying data, and sets of correlated topics are together gathered as clusters that denote motive. Predators and Victims are mapped to motive assignments, and then a topic is selected based on these motives. The intention of each and every predator has a multinomial distribution on topics, and every topic has a multinomial distribution on words. First, the motive assignments can be made separately for each word in a document. This model represents that someone can change motive during the

exchange of the messages.

*Cyberspace*

**Figure 1.**

**152**

*Graphical model for B-LDA.*

	- i. choose topic zdn � θzd
	- ii. choose word wdn � ϕzdn

In this model for a particular message d, given the hyper parameters α, β, and γ, the predator pd, and set of victims vd, the connected dispersion of an author blend θ, a motive blend ψ, a topic blend ϕ, a set of Nd victims yd, and a set of Nd predator motives xd, a set of Nd topics zd and a set of Nd words wd is assigned by,

$$\begin{aligned} p(\theta, \phi, \psi, yd, \text{zd}, \text{zd}, \text{wd}|a, \beta, \gamma, pd, \text{vd}) \\ &= p(\psi|\gamma)p(\theta|\alpha)p(\phi|\beta) \\ &= \prod\_{n=1}^{Nd} p(\text{ydn}|\nu d)p(\text{xd}|\text{pd})p(\text{zd}n|\theta \text{xd}n)p(\text{wd}|\phi \text{zd}n) \end{aligned} \tag{1}$$

Integrating over γ, θ and ϕ and summing over yd, xd, and zd, the marginal distribution of a document is calculated as follows:

$$\begin{aligned} p(wd|a,\beta,\chi,pd,vd) &= \iiint p(\psi|\gamma)p(\theta|a)p(\phi|\beta) \\ \prod\_{n=1}^{Nd} \sum\_{pdn} \sum\_{xdn} \sum\_{zdn} p(ydn|vd)p(\mathbf{x}dn|pd)p(\mathbf{z}dn|\theta \mathbf{x}dn)p(\mathbf{w}dn|\phi \mathbf{z}dn)d\eta d\phi d\theta \end{aligned} \tag{2}$$

Then the product of the marginal probabilities of single documents, and the probability of a corpus is computed as,

$$p(D|a,\beta,\gamma,p,v) = \prod\_{d=1}^{D} p(wd|a,\beta,\gamma,pd,vd) \tag{3}$$

#### **3.1 Monte Carlo Gibbs sampling**

The assumption on models in the LDA family cannot be carried out correctly. Three standard approximations have been occupied to acquire practical results:

Variational methods [12], Gibbs sampling [13], and expectation propagation [14]. As Gibbs sampling is easy to implement, it has been applied here. There is a need to derive a formula to carry out the Gibbs sampling for P(zi,yi,xi|z-i,y-i,x-i), the conditional distribution of a topic and victims for w word given all other words topic and victim assignment, the motive of the predator, z-i, y-i, and x-i. In order to calculate P(z,y,x|w), the posterior distribution of topic, victim assignments and the motive of the predator given the words in the corpus.

The calculations begin with P(w|z,x), using P(w|z,x,Φ) in order to integrate out the unknown <sup>Φ</sup> distributions to obtain: *P w*ð Þ¼ <sup>j</sup>*z*, *<sup>y</sup>*, <sup>Φ</sup> <sup>Q</sup>*<sup>W</sup> iw*¼1*ϕziw Wiw* ð Þ.

Reorganizing the product over the W word token exist in the corpus to collect words that are assigned to the same bullying topic,

$$P(w|z, \mathcal{y}, \Phi) = \prod\_{x=1}^{T} \prod\_{u=1}^{U} \phi\_x^{n\_x^{\text{new}}} \tag{4}$$

Hence the denominator cannot be calculated directly. The following equations

Γ *n<sup>t</sup> <sup>p</sup>* þ *αt* � �

� �

*<sup>p</sup>* � 1 þ *αt* � �

*<sup>p</sup>* � <sup>1</sup> <sup>þ</sup> <sup>P</sup>

*nwu <sup>t</sup>*,�*<sup>i</sup>* <sup>þ</sup> *<sup>β</sup><sup>u</sup>*

*<sup>u</sup>nt*,�*<sup>i</sup>* <sup>þ</sup> <sup>P</sup>

� �

P

*<sup>z</sup>αz*

Γ *nwu <sup>t</sup>* <sup>þ</sup> *<sup>β</sup><sup>u</sup>* � �

Γ *nwu*

*<sup>t</sup>* � <sup>1</sup> <sup>þ</sup> *<sup>β</sup><sup>u</sup>* � �

1

CCCCCCCA

(9)

*<sup>t</sup>* � <sup>1</sup> <sup>þ</sup> <sup>P</sup> *<sup>u</sup>β<sup>u</sup>* � �

Γ P *unwu <sup>t</sup>* <sup>þ</sup> <sup>P</sup> *<sup>u</sup>β<sup>u</sup>* � �

Γ P *unwu*

*<sup>u</sup>βu*

Γ P *znz <sup>p</sup>* <sup>þ</sup> <sup>P</sup> *<sup>z</sup>αz*

Γ *nt*

*<sup>z</sup>αz*

where the victim, y is part of Predator-Victim pair, *p*, the –i subscript is used to denote that the counts are taken by excluding the assignment of word *i* itself, and *nR*

In this chapter, the experimental results are discussed. The datasets used in these experiments are tweets from Twitter. An experiment has been conducted on tweets based on the architecture of an automatic cyber bullying detection system. Search is made in the Twitter stream for Tweets containing the strings that

contain offensive words so as to particularly filter for tweets related to bullying. In total, more than 1,00,000 tweets are gathered between Jan 1st, 2015 and Jan 30th, 2016. A limit number of tweets are matching with the query. So, approximately 300 tweets are filtered per day. The statistics for training and the testing corpus is given in **Table 1**. Tweets were manually labeled as belonging to one of the different

motives namely Sexual, Racist, Outrage, Irrelevant, and Unknown after the preprocessing. The examples of harassing comments posted on Twitter are listed below and depicted in **Figure 2(a)** and **(b)** and top bullying words which are

09–18-15 11:51 TittyCityClay it's always been a self respect thing. Shit like this is stupid

05–13-15 10:11 djkeneechi Nah kiss no one ass to stay in my life anymore im tired of that shit it's

Γ P *znz*

*<sup>p</sup>*,�*<sup>i</sup>* <sup>þ</sup> <sup>P</sup>

*nt <sup>p</sup>*,�*<sup>i</sup>* <sup>þ</sup> *<sup>α</sup><sup>t</sup>*

are used to run a MCMC Gibbs sampling calculation by using the conditional

distribution P(zi, yi, xi, wi|z-i, y-i, x-i, w-i).

*Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

*P zi* ð Þ , *yi*, *xi*, *wi*j*z* � *i*, *y* � *i*, *x* � *i*, *w* � *i*

<sup>¼</sup> *P z*ð Þ , *<sup>y</sup>*, *<sup>x</sup>*, *<sup>w</sup>*

0

BBBBBBB@

P *znz*

**3.2 Experiments and results**

**Date Time Tweets**

**155**

¼ 1 *nR*

¼ 1 *nR*

*P z*ð Þ � *i*, *y* � *i*, *x* � *i*, *w* � *i*

Γ *nt <sup>m</sup>* <sup>þ</sup> *<sup>γ</sup><sup>t</sup>* � �

*<sup>m</sup>* � <sup>1</sup> <sup>þ</sup> *<sup>γ</sup><sup>t</sup>* � �

*<sup>m</sup>* � <sup>1</sup> <sup>þ</sup> <sup>P</sup> *<sup>z</sup>γ<sup>z</sup>* � �

*<sup>z</sup>γz*

P *znz*

is the number of Victims for the message to which word *i* belongs.

Γ P *znz <sup>m</sup>* <sup>þ</sup> <sup>P</sup> *<sup>z</sup>γ<sup>z</sup>* � �

Γ P *znz*

> *nt <sup>m</sup>*,�*<sup>i</sup>* <sup>þ</sup> *<sup>γ</sup><sup>t</sup>*

Γ *nt*

*<sup>m</sup>*,�*<sup>i</sup>* <sup>þ</sup> <sup>P</sup>

extracted are given in **Table 2** (**Figures 3**–**5**).

as fuck lol

01–13-15 12:16 NefarioussNess Do not fuck with people's hearts

time for me to man up

where *nz wu* is the number of times that a bullying word, wu was assigned to a bullying topic. To integrate out the ϕ distribution by using the Dirichlet distributions,

$$\begin{split} p(w|z,\boldsymbol{y}) &= \int \prod\_{z=1}^{T} \left( \frac{\Gamma\left(\sum\_{u=1}^{U} \beta u\right)}{\prod\_{u=1}^{U} \Gamma(\beta u)} \left( \prod\_{u=1}^{U} \phi\_{x}^{u\_{z}^{ww} + \beta u - 1}(wu) d\phi\_{x}(wu) \right) \right) \\ &= \prod\_{z=1}^{T} \left( \frac{\Gamma\left(\sum\_{u=1}^{U} \beta u\right)}{\prod\_{u=1}^{U} \Gamma(\beta u)} \left( \frac{\prod\_{u=1}^{U} \Gamma\left(\eta\_{x}^{wu} + \beta u\right)}{\Gamma\left(\sum\_{u=1}^{U} \beta u + \sum\_{u=1}^{U} \eta\_{x}^{wu}\right)} \right) \right) \end{split} \tag{5}$$

In the same manner, P(z,y) is computed using a procedure analogous to that used for P(w|z,y). The collected terms of bullying words are assigned to the same topic and predator-victim pair and integrate out the Θ distributions corresponding to all the different predator-victim pairs, P:

$$P(\mathbf{z}, \mathbf{y}) = \left(\prod\_{i \le \mathbf{z} = 1}^{W} \frac{\mathbf{1}}{n\_{\mathbb{R}}(diw)}\right) \prod\_{p=1}^{P} \left(\frac{\Gamma\left(\sum\_{\mathbf{z}} \alpha \mathbf{z}\right)}{\prod\_{\mathbf{z}=1}^{T} \Gamma(\alpha \mathbf{z})} \frac{\prod\_{\mathbf{z}} \Gamma\left(n\_{\mathbf{p}}^{\mathbf{z}} + a\_{\mathbf{z}}\right)}{\Gamma\left(\sum\_{\mathbf{z}} a\_{\mathbf{z}} + \sum\_{\mathbf{z}} n\_{\mathbf{p}}^{\mathbf{z}}\right)}\right) \tag{6}$$

where *nR diw* ð Þ is the number of victims corresponding to a word in a message.

Similarly can calculate P(z, x) using a procedure analogous to that used for P (w|z, x). Bullying words have been assigned to the same topic and the motivation of the predator can be computed as,

$$P(\boldsymbol{z},\boldsymbol{\chi}) = \left(\prod\_{i \neq -1}^{W} \frac{1}{n\_S(di\boldsymbol{\nu})}\right) \prod\_{p=1}^{P} \left(\frac{\Gamma\left(\sum\_{\boldsymbol{x}} \chi\_{\boldsymbol{x}}\right)}{\prod\_{\boldsymbol{x}=1}^{T} \Gamma(\boldsymbol{\chi}\boldsymbol{\pi})} \frac{\prod\_{\boldsymbol{x}} \Gamma\left(\boldsymbol{n}\_{\boldsymbol{m}}^{\boldsymbol{x}} + \chi\_{\boldsymbol{x}}\right)}{\Gamma\left(\sum\_{\boldsymbol{x}} \chi\_{\boldsymbol{x}} + \sum\_{\boldsymbol{x}} \boldsymbol{n}\_{\boldsymbol{m}}^{\boldsymbol{x}}\right)}\right) \tag{7}$$

where *nS diw* ð Þ is the number of predators having bad motivation with respect to the bullying word in a message. An expression for P (w, z, y, x) can be achieved by combining the equations of P(w|z, y), P(z, y) and P(z, x). This can be used to write an expression for the posterior distribution of z, y and x given the corpus,

$$P(\mathbf{z}, \mathbf{y}, \mathbf{x} | w) = \frac{P(w, \mathbf{z}, \mathbf{y}, \mathbf{x})}{\sum\_{\mathbf{z}, \mathbf{y}, \mathbf{x}} P(w, \mathbf{z}, \mathbf{y}, \mathbf{x})} \tag{8}$$

*Classification Model for Bullying Posts Detection DOI: http://dx.doi.org/10.5772/intechopen.88633*

Hence the denominator cannot be calculated directly. The following equations are used to run a MCMC Gibbs sampling calculation by using the conditional distribution P(zi, yi, xi, wi|z-i, y-i, x-i, w-i).

$$P(
\text{z}
\text{i}, 
\text{yi}, 
\text{x}i, 
\text{w}
\text{i}|
\text{z}-
\text{i}, 
\text{y}-
\text{i}, 
\text{x}-
\text{i}, 
\text{w}-
\text{i}).$$

Variational methods [12], Gibbs sampling [13], and expectation propagation [14]. As Gibbs sampling is easy to implement, it has been applied here. There is a need to derive a formula to carry out the Gibbs sampling for P(zi,yi,xi|z-i,y-i,x-i), the conditional distribution of a topic and victims for w word given all other words topic and victim assignment, the motive of the predator, z-i, y-i, and x-i. In order to calculate P(z,y,x|w), the posterior distribution of topic, victim assignments and the

The calculations begin with P(w|z,x), using P(w|z,x,Φ) in order to integrate out

Reorganizing the product over the W word token exist in the corpus to collect

*T*

Y *U*

*u*¼1 *ϕnz wu*

*z*¼1

*wu* is the number of times that a bullying word, wu was assigned to a bullying topic. To integrate out the ϕ distribution by using the Dirichlet distributions,

*ϕ<sup>n</sup>wu*

*<sup>u</sup>*¼<sup>1</sup><sup>Γ</sup> *nwu*

*<sup>u</sup>*¼<sup>1</sup>*β<sup>u</sup>* <sup>þ</sup> <sup>P</sup>*<sup>U</sup>*

� �

0 !

*<sup>z</sup>* <sup>þ</sup>*βu*�<sup>1</sup> *<sup>z</sup>* ð Þ *wu <sup>d</sup>ϕz*ð Þ *wu*

*<sup>u</sup>*¼<sup>1</sup>*nwu z*

1 A

*<sup>p</sup>* þ *α<sup>z</sup>* � �

*<sup>m</sup>* þ *γ<sup>z</sup>* � �

> *znz m*

*<sup>z</sup>γ<sup>z</sup>* <sup>þ</sup> <sup>P</sup>

� �

*znz p* 1

A (6)

(7)

(8)

*<sup>z</sup>α<sup>z</sup>* <sup>þ</sup> <sup>P</sup>

� �

1 A

*<sup>z</sup>* <sup>þ</sup> *<sup>β</sup><sup>u</sup>* � �

Q *<sup>z</sup>*Γ *nz*

Γ P

Q *<sup>z</sup>*Γ *nz*

!

Γ P

Y *U*

*u*¼1

Γ P*<sup>U</sup>*

In the same manner, P(z,y) is computed using a procedure analogous to that used for P(w|z,y). The collected terms of bullying words are assigned to the same topic and predator-victim pair and integrate out the Θ distributions corresponding

> Γ P *<sup>z</sup>α<sup>z</sup>* � �

> > *<sup>z</sup>*¼<sup>1</sup>Γð Þ *<sup>α</sup><sup>z</sup>*

Q*<sup>T</sup>*

where *nR diw* ð Þ is the number of victims corresponding to a word in a message. Similarly can calculate P(z, x) using a procedure analogous to that used for P (w|z, x). Bullying words have been assigned to the same topic and the motivation of

> Γ P *zγz* � �

> > *<sup>z</sup>*¼<sup>1</sup>Γð Þ *<sup>γ</sup><sup>z</sup>*

*P w*ð Þ , *z*, *y*, *x*

*<sup>z</sup>*,*y*,*<sup>x</sup>P w*ð Þ , *z*, *y*, *x*

Q*<sup>T</sup>*

where *nS diw* ð Þ is the number of predators having bad motivation with respect to the bullying word in a message. An expression for P (w, z, y, x) can be achieved by combining the equations of P(w|z, y), P(z, y) and P(z, x). This can be used to write an expression for the posterior distribution of z, y and x given the corpus,

P

Q*<sup>U</sup>*

*P w*ð Þ¼ <sup>j</sup>*z*, *<sup>y</sup>*, <sup>Φ</sup> <sup>Y</sup>

*iw*¼1*ϕziw Wiw* ð Þ.

*<sup>z</sup>* (4)

1 A

(5)

motive of the predator given the words in the corpus.

words that are assigned to the same bullying topic,

ð Y *T*

*z*¼1

0 @

<sup>¼</sup> <sup>Y</sup> *T*

*z*¼1

to all the different predator-victim pairs, P:

*W*

*iw*¼1

*W*

*iw*¼1

*P z*ð Þ¼ , *<sup>y</sup>* <sup>Y</sup>

the predator can be computed as,

**154**

*P z*ð Þ¼ , *<sup>x</sup>* <sup>Y</sup>

@

where *nz*

*Cyberspace*

*p w*ð Þ¼ j*z*, *y*

the unknown <sup>Φ</sup> distributions to obtain: *P w*ð Þ¼ <sup>j</sup>*z*, *<sup>y</sup>*, <sup>Φ</sup> <sup>Q</sup>*<sup>W</sup>*

Γ P*<sup>U</sup>*

Q*<sup>U</sup>*

Γ P*<sup>U</sup>*

Q*<sup>U</sup>*

*<sup>u</sup>*¼<sup>1</sup>*β<sup>u</sup>* � �

*<sup>u</sup>*¼<sup>1</sup>Γð Þ *<sup>β</sup><sup>u</sup>*

0 @

*P*

0 @

*p*¼1

*P*

*p*¼1

*<sup>u</sup>*¼<sup>1</sup>*β<sup>u</sup>* � �

*<sup>u</sup>*¼<sup>1</sup>Γð Þ *<sup>β</sup><sup>u</sup>*

1 *nR*ð Þ *diw* !Y

1 *nS*ð Þ *diw* !Y

*P z*ð Þ¼ , *y*, *x*j*w*

$$\begin{aligned} \mathbf{P} &= \frac{P(z, \mathbf{y}, \mathbf{x}, \boldsymbol{w})}{P(z - i, \mathbf{y} - i, \mathbf{x} - i, \mathbf{w} - i)} \\\\ &= \frac{1}{nR} \left( \frac{\Gamma\left(n\_{m}^{t} + \eta\right)}{\frac{\Gamma\left(\sum\_{x} n\_{m}^{x} + \sum\_{x} \eta\right)}{\Gamma\left(n\_{m}^{t} - \mathbf{1} + \eta\right)}} \frac{\frac{\Gamma\left(n\_{p}^{t} + a\mathbf{t}\right)}{\Gamma\left(\sum\_{x} n\_{p}^{x} + \sum\_{x} \eta\right)} \frac{\Gamma\left(n\_{t}^{wu} + \beta u\right)}{\Gamma\left(\sum\_{x} n\_{t}^{wu} + \sum\_{x} \eta\right)}}{\Gamma\left(\sum\_{x} n\_{m}^{x} - \mathbf{1} + \sum\_{x} \eta\right)} \frac{\Gamma\left(n\_{t}^{w} - \mathbf{1} + \eta\right)}{\Gamma\left(\sum\_{x} n\_{t}^{wu} - \mathbf{1} + \sum\_{x} \eta\right)} \right) \\\\ &= \frac{1}{nR} \frac{n\_{m, -i}^{t} + \eta t}{\sum\_{x} n\_{m, -i}^{x} + \sum\_{x} \eta z \sum\_{p, -i} + \sum\_{x} \eta z} \frac{n\_{t, -i}^{wu} + \beta u}{\sum\_{x} n\_{t, -i} + \sum\_{x} \eta u} \end{aligned} \tag{9}$$

where the victim, y is part of Predator-Victim pair, *p*, the –i subscript is used to denote that the counts are taken by excluding the assignment of word *i* itself, and *nR* is the number of Victims for the message to which word *i* belongs.

#### **3.2 Experiments and results**

In this chapter, the experimental results are discussed. The datasets used in these experiments are tweets from Twitter. An experiment has been conducted on tweets based on the architecture of an automatic cyber bullying detection system. Search is made in the Twitter stream for Tweets containing the strings that contain offensive words so as to particularly filter for tweets related to bullying. In total, more than 1,00,000 tweets are gathered between Jan 1st, 2015 and Jan 30th, 2016. A limit number of tweets are matching with the query. So, approximately 300 tweets are filtered per day. The statistics for training and the testing corpus is given in **Table 1**. Tweets were manually labeled as belonging to one of the different motives namely Sexual, Racist, Outrage, Irrelevant, and Unknown after the preprocessing. The examples of harassing comments posted on Twitter are listed below and depicted in **Figure 2(a)** and **(b)** and top bullying words which are extracted are given in **Table 2** (**Figures 3**–**5**).

