Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Threat Prediction Based on Opinion Extracted from Twitter

Zerihun Tolla Tibebe Beshah


HiLCoE, Computer Science Programme, Ethiopia HiLCoE, Ethiopia
wanofii@gmail.com School of Information Science, Addis Ababa
University, Ethiopia
tibebe.beshah@gmail.com

Abstract
The availability of technology and infrastructure create opportunities for citizens to publicly voice their
opinions over social media, but this has created serious problems when it comes to making sense of these
opinions. Government and companies don’t yet have an effective way to make sense of this users’ conversation
and interact importantly with thousands of others. Huge amount of opinions are posted and tweeted on the Web.
Such opinions are a very important source of information for governments and companies. A lot of researchers
describe that users are relying on online opinions to make effective use of user opinions. Unfortunately, due to
the increasing number of social media users, many government-opposing groups use access of the web to
initiate people in anti-government protests and for violent actions. Many researches are being conducted in the
domain and many attempts to approach the topic have been presented. However, researches conducted so far,
using opinion mining for threat prediction are rare. In this research, we present how to model and automatically
monitor trends and detect opinions which are considered as threats on Twitter. Specifically, we propose a
supervised machine learning algorithm which classifies opinions using n-bag of word features.
Keywords: Opinion Mining; Text Classification; Machine Learning

1. Introduction Because of the widely accessible and available


data in electronic format on social media, developing
The advance of technology to access the Internet
a systematic approach is necessary, as it helps
and the availability of enormous data on the web has
researchers, organizations, and governments to
motivated most of the research groups [1, 2]. The
understand the commonality in various online text
significant role of analyzing social media and web
data. Using the extracted information from social
networks to improve our knowledge of information
media, researchers can acquire valuable perceptions
sharing, maintaining communication, opinion
into the beliefs, values and attitudes of social media
formation, and dissemination has been accepted [3, 4,
users with regard to the utility of user-written opinion
5]. But, quantitative studies of the social media
and formation [7, 8]. The available information on
content, especially on opinion mining and information
social web can help governments to monitor the
technology management, remain rare [5].
awareness of people regarding violent actions taken
Considerable obstacle to social media usage is lack of
using social networks and aid governments in
efficient methodology for selecting, collecting, pre-
strategic planning.
processing, and analyzing contextual information
obtained from the web. However, in the field of The grounded theory approaches studied in [9]
opinion mining, many companies have developed analyze social media content and identify the
their own or proprietary text mining systems for data underlying factor structure of collected information to
analysis [6], and researchers in the field of big data address the gap between the availability of user-
analytics have developed expert systems for fraud written raw text and the contextual information of
detection, spam detection and sentiment analysis [3]. aggregated data. Nowadays many threats to people
and infrastructures can be related to the activities of
HiLCoE Journal of Computer Science and Technology, Vol. 3, No. 1 73 

people on social media, blogs and forums. Social It is shown that machine learning is a good and
media platforms like social networks and micro blogs vital tool for sentiment analysis for product and movie
allow users to share messages with others. The reviews from a corpus. For such a case three known
amount of data on social media is rapidly increasing machine learning algorithms are applied: Naïve
and it is difficult to monitor the continuous flow of Bayes, maximum entropy, and support vector
tweets, blogs, opinions and comments and on machines. The threat or failure cascaded across
websites. Looking at the growth of Internet users and infrastructures has been identified as a key challenge
the activities of people on websites, researchers are for governments [14]. Infrastructure security could be
motivated to do research in the area of opinion increased by automated detection of deviant behaviors
mining. Overall the intent of this paper is to develop as stated in [15].
predictive model that takes people’s opinion on There are opportunities for social media such as
twitter blogs and classifies the tweets as active threat, Facebook, Twitter and weblogs to help the timely,
past threat and normal message. comprehensive and transparent spreading of
2. Related Work information [16]. However, the automatic analysis of
social media requires other methods than usual
In the field of opinion mining, several efforts have
opinion or text analysis. The social media provide
been made to predict or classify threatening or
huge amounts of visual data which can be analyzed to
offensive texts. Prediction of offensive text methods
use textual information for anomaly detection [17].
are described in [10] for detecting offensive languages
The authors in [18] tried to predict upcoming
in social media. Weak words and strong offensive
events in the future based on micro blog messages
words, combined with text mining techniques, are
from social media. They developed a model that
also used in sentiment analysis appraisal approach,
selects the most relevant information during big
like n-grams, Bag-of-Words. They also try to classify
events and incidents. A lot of researches have been
users as being offensive or not.
done so far on opinion mining related to improving
In [11] approaches for text mining to detect
business by reviewing user opinion commented on
cybercrime like Internet predation and cyber bullying
products. To the best of our knowledge and reviewing
are discussed, both via rule-based and statistical
related works, using user opinion for predicting is rare
approaches. Data mining techniques have been
except the work in [19] which tried to develop a
applied to detect and alert suspicious e-mails, coming
model to predict early threats from user tweets in
from terrorists, using machine learning algorithms,
Dutch language. In this paper, we use the previous
emphasizing initially on creating the feature space,
work on opinion mining as a guide and different data
and then applying different feature selection
mining techniques as methodology to develop threat
techniques as stated in [12]. Setting supervised
predictive model from users’ opinion in English
learning using Decision Tree, which seems to
language.
outperform methods like supervised vector machine
and Naïve Bayes are also used to classify threat e- 3. The Proposed Solution
mails [13]. Our proposed method to classify opinion as a
Kim et al. [8] give an approach for sentiment threat or not is an implementation of supervised
analysis in case of using twitter list from a corpus. In machine learning using SVM Classifier. We have
this context, lists are groups of users who share a used a twitter developer API and Rstudio to scrawl
common interest. Tweets contain enough information user opinions from Twitter. After opinions are
to express identifiable characteristics, interests and extracted and preprocessed we used grammar and
sentiments. tense to label the training data sets. Finally,
74 Threat Prediction Based on Opinion Extracted from Twitter

supervised classifiers built in RTextTools are trained performance and accurately classify test data. Over all
using n-bag of words as features sets. We also set a the complete proposed system consists of the
parameter to select the algorithm with the best components shown in Figure 1.

 
Figure 1: Overview of the Research Process

4. Experiment and Results machine learning package for automatic text


classification that makes it simple for users having a
4.1 Overview
little knowledge of object oriented programming to
We experimentally tested our approach using get started with machine learning, while allowing
datasets that we collected from Twitter. We converted experienced users to easily experiment with different
the datasets into a relational database to make it easier settings and algorithm combinations. The package
to process and extract features. We extracted only the includes nine algorithms for ensemble classification
message from the body of tweets because the rest of (svm, slda, boosting, bagging random forests, glmnet,
attributes are not important to classify the text for our decision trees, neural networks, and maximum
research objective. In order to see whether the entropy), comprehensive analytics, and thorough
extracted tweets can be predicted or not, we prepared documentation. For conducting our experiment, we
a data set containing 500 tweets labeled as past threat selected five classification algorithms to classify
activity, 500 tweets having no threat words which are opinions to three class labels. The class labels are
purely normal tweets and 500 tweets labeled as active coded as -1, 0, 1 representing past threat, normal
threats. Five selected classifiers are trained based on message and active threat respectively.
the n-bag of words features that we extracted.
All experiments are first run on the dataset using
4.2 Experimental Setting 10-fold cross validation (cross_validate() function in
As the first step in developing predictive RTextTools library) to test the validity of our data sets
classification model, we selected the actual modeling on each algorithm and 75/25 percentage split. Finally,
technique to be used. We used RTextTools which is a we get the result shown in Table 1.
Table 1: Summary of Experiments

Experiment Algorithm Test Technique Accuracy %


1 SVM 10 fold cross validation 0.92
2 MaxEnt 10 fold cross validation 0.01
3 Random forest 10 fold cross validation 0.88
4 NNETWORK 10 fold cross validation 0.73
HiLCoE Journal of Computer Science and Technology, Vol. 3, No. 1 75 

Experiment Algorithm Test Technique Accuracy %


5 TREE 10 fold cross validation 0.73
6 GLMNET 10 fold cross validation 3
7 SVM 75/25 percentage split 97.87
8 NNETWORK 75/25 percentage split 73.8
9 Random forest 75/25 percentage split 85.6

4.3 Results and Discussion document representation and analysis of opinion


The main objective of this paper is building a extracted from Twitter. We presented a method that
threat predicting model that helps organizations to can automatically detect threatening and abnormal
predict threat based on user opinion collected from activities in the real world based on information
Twitter. To study the domain and achieve the collected from Twitter. We showed a way to extract
objective, a tool to collect and conduct experiments user opinion from Twitter and defined features that
has been identified. Finally, a predictive model analyze the content of messages, such as active
which predicts threats is built. threat, past threat and pure messages. These features
The classifiers that we adopted in this work are: are trained on messages that were selected with a
SVM, MaxEnt, Random Forest, NNETWOR, TREE short list of query keywords. This list can easily be
and GLMNET. As each algorithm uses different modified and extended to refine the existing features
parameters and techniques to learn from the training or to define new categories for another domain. The
data, we did several experiments. In order to find the grammar and vocabulary used in a sentence separates
optimal classifier which correctly classifies our data, the type of activities. In combination with our post-
we performed all experiments with cross-validation processing steps, we are able to report threats and
and make sure that the parameters are not optimized demonstrate activities that have a great impact on a
for one particular test set and performed the nation’s security. We experimentally tested our
experiment using 75/25 percentage split of the data approach using datasets that we collected from
sets by doing 10-fold cross validation experiment Twitter. The datasets were collected using the
which works on full data set. Finally, according to Twitter steaming API. We converted the datasets into
the criteria stated above and evaluation technique, to a relational database to make it easier to process data
test our model on actual data, we conducted one and extract features. The existing classification
experiment using new data. For this purpose, we methods are compared and contrasted based on their
prepared 10 instances of tweets and check if our accuracy.
model predicts the instance to predefined class labels. We use n-bag of words feature of tweets to train
The results achieved by applying the selected data the classifier. We will extend it by extracting several
mining algorithm (SVM) for classification on the user-based and tweet-based features from the body of
collected data reveal that our model has an overall tweets and the users who published the tweet.
accuracy of 97.87%. Furthermore, we will add additional features from the
network of the users which is believed to be very
5. Conclusion and Future Work
informative.
The growing use of opinion on social media needs In this work we examined several classifiers
text mining, machine learning, and natural language independently. One interesting extension to our work
processing techniques and methodologies to organize would be to implement fusion and boosting methods
and extract pattern and classifying user opinion. This to combine all the classifiers and benefit from the
paper focused on the existing literature and explored advantages of all.
76 Threat Prediction Based on Opinion Extracted from Twitter

Another extension to our work would be to [10] Chen, Y., Zhu, S., Zhou, Y., Xu, H., “Detecting
implement some feature engineering methods such as Offensive Language in Social Media to Protect
feature extraction to see if more efficient and Adolescent Online Safety”, ASE/IEEE Int.
accurate classifies can be trained. Also techniques Conf. Social Computing SocialCom, 2012.
such as query expansion can be applied to exploit [11] Kontostathis, A., Edwards, L., Leatherman, A.,
“Text Mining and Cybercrime”, Text mining –
additional auxiliary information, labeling of the text
Applications and Theory, 2010.
and developing a dictionary of a threat word to
[12] Nizamani, S., Memon, N., Wiil, and U. K.,
improve the performance of our classifiers.
Karampelas, P., “Modeling Suspicious E-mail
References Detection Using Enhanced Feature Selection”,
Int. J. Modeling and Optimization 2 (4), 2012.
[1] Csorgo, M., Horváth, L., “Limit Theorems in
[13] Appavu alias Balamurugan, S., “Learning to
Change-Point Analysis”, Wiley, 1997.
Classify Threatening e-mail”, IEEE Int. Conf.
[2] Denning, D., “An Intrusion-Detection Model”,
Modeling and Simulation AICMS, 522-527,
IEEE T. Softw. Eng. 13(2), pp. 222-232, 1987.
2008.
[3] Abrahams, A. S., J. Jiao, G. A. Wang, and W.
[14] Eeten, M. van, Nieuwenhuijs, A., Luiijf, E.,
G. Fan, “Vehicle Defect Discovery from Social
Klaver, M., and Cruz, E., “The State and the
Media,” Decision Support Systems, Vol. 54, No.
Threat of Cascading Failure across Critical
1:87-97, 2012.
Infrastructures: The Implications of Empirical
[4] Airoldi, E. M., X. Bai, and R. Padman,
Evidence from Media Incident Reports”, Public
“Markov-blanket and Meta-heuristic Search:
Administration 89(2), 381-400, 2011.
Sentiment Extraction from Unstructured Text,”
[15] Burghouts, G. J., Hollander, R., Schutte, E. A.,
Lecture Notes in Computer Science, Vol.
“Increasing the Security at Vital Infrastructures:
3932:167-187, 2006.
Automated Detection of Deviant Behaviors”,
[5] Bai, X., “Predicting Consumer Sentiments from
Proc. SPIE 8019, 2011.
Online Text,” Decision Support Systems, Vol.
[16] Kleij, R. van der, Vries, A. de, Faber, W.,
50, No. 4:732-742, 2011.
“Opportunities for Social Media in the
[6] Arnold, E., A. Bruton, and C. Ellis-Hill,
Comprehensive Approach”, NATO RTO-MP-
“Adherence to Pulmonary Rehabilitation: A
HFM-201, 2012.
Qualitative Study,” Respiratory Medicine, Vol.
[17] Schavemaker, J, Eendebak, P., Staalduinen, M.,
100, No. 10:1716-1723, 2006.
and Kraaij, W., “Notebook Paper: TNO Instance
[7] Karimov, F. P., M. Brengman, and L. Van
Search Submission 2011”, Proc. TRECVID,
Hove, “The Effect of Website Design
2011.
Dimensions on Initial Trust: A Synthesis of the
[18] Weerkamp, W., and Rijke, M. de, “Activity
Empirical Literature,” Journal of Electronic
Prediction: a Twitter-based Exploration”, SIGIR
Commerce Research, Vol. 12, No. 4:272-301,
Workshop on Time-aware Information Access,
2011.
2012.
[8] Kim S. B., Rim H. C., Yook D. S., and Lim H.
[19] Bouma, H., Raaijmakers, S., Halma, A., and
S., “Effective Methods for Improving Naïve
Wedemeijer, H., “Anomaly Detection for
Bayes Text Classifiers”, LNAI 2417, 2002, pp.
Internet Surveillance”, Proc. SPIE, Vol. 8408,
414-423.
2012.
[9] Strauss, A. and J. Corbin, “Basics of Qualitative
Research: Techniques and Procedures for
Developing Grounded Theory”, CA, Thousand
Oaks: Sage Publications, 1998.

You might also like