**1. Introduction**

Sentiment analysis uses linguistic and textual assessment, such as natural language processing to analyze word use, word order, and word combinations and thus to classify sentiments, often into the categories of positive, negative, or neutral polarity. Data gathered through sentiment analysis is believed to provide detailed information about something to which direct access did not previously exist: public opinion and feeling [1]. This research performs sentiment analysis by monitoring and analyzing local trending topics that create

Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. © 2018 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/3.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

© 2016 The Author(s). Licensee InTech. This chapter is distributed under the terms of the Creative Commons

a stir socially in Jamaica including President Barack Obama's historic working visit to the island country [2]. The aim of the study is to analyze the opinions and emotion expressed by citizens based on these topical issues and classifies them by emotions, feelings and polarity. It utilizes three machine learning algorithms to classify citizens perceptions namely decision tree J48, PART and naive bayes; and identifies the accuracy of the data classified based on the polarity. The classifiers identified the polarity reflected and which opinion is more dominant of the three (negative, positive or neutral). Research was undertaken on four topical issues in Jamaica: (1) The decriminalization of marijuana in Jamaica (2) Kaci Fennell's placing in the Miss Universe competition (3) The Riverton Landfill fire and (4) Barack Obama's working visit to Jamaica.

**2.3. Data classification**

**2.4. Data analysis**

graphs and tables.

**3.1. Polarity of topical issues**

**3. Results**

RStudio provided two functions that analyzed the tweets and classified them into polarity (negative, neutral and positive) and emotion (joy, anger, fear, surprise). Analysis was done both on tweets (not re-tweeted) as well as re-tweets. After compiling the polarity function to classify the tweets into negative, positive and neutral polarities, the team observed that a number of tweets were classified incorrectly. This was a result of R's inability to understand the Jamaican dialect and RStudio's limited dictionary of words. Classifying tweets into emotions proved to be another challenge as majority of the tweets for the different topical issues returned a result of "unknown" for the emotion associated with the tweet. Both these tools, which are essential components of the sentiment analysis research being conducted, were somewhat ineffective in describing and classifying the data that was collected from Twitter.

Using Sentiment Analysis and Machine Learning Algorithms to Determine Citizens' Perceptions

http://dx.doi.org/10.5772/intechopen.72521

67

The WEKA software was used offline to analyze data during pre- processing, classification and the post processing. In order to process the data gathered from the Twitter API, the file type or dataset was formatted to a file extension of .arff (attribute file format) and this file extension is generated from a.csv (comma-separated values) file which separates each attribute by a comma. The .arff file is an ASCII text file that describes a list of instances sharing a set of attributes.

A spreadsheet application was another useful tool in the sentiment analysis research conducted. This tool allowed one to inspect the comma-separated values files and also create

This section outlines the classification of tweets downloaded for each of the four topical issues. It shows how sentiment analysis of tweets can be used to explore the citizens perceptions on the topical issues selected. **Figure 1** below shows the summary and classification of such tweets.

Citizens from varying demographics express their opinions on Twitter on several topical issues. The four step methodology was executed and tweets were classified by the machine learning algorithms as shown in **Figure 1**. Barack Obama's visit to Jamaica represented the fourth bar among the quartet of tweets, received 2583 positive tweets and 658 negative tweets

The next section will present results on polarity of topical issues for tweets and no-retweets.

A typical approach to sentiment analysis is to start with a lexicon of positive and negative words and phrases [4]. Polarity describes whether a word seems to evoke something positive

and the highest total tweets among the 4 topics investigated.
