Infosys’ blog on industry solutions, trends, business process transformation and global implementation in Oracle.

« Enabling CA Signed Certificate in Oracle JCS and On-Premise Weblogic | Main | Platformization at Telcos »

Sentiment Analysis with Twitter data using Oracle Analytics Cloud

Oh! human sentiments can be analyzed is it ?!!(my first thought when I heard about this couple of months back J)

So started digging and thought of sharing an end to end view on how it can be achieved.

First of all, analysis is all about data. To do Sentiment Analysis, we need data about our ideas, emotions, feelings, likes, dislikes ...etc. So primary source for this data would be social network like Facebook, Twitter ...etc.

Outcomes of a Sentiment Analysis can be categorized under Polarity and Subjectivity.

Polarity is about - Negative, Neutral or Positive

Subjectivity is about - Objective or Subjective

Below I am going to explain the steps to do Sentiment Analysis for Polarity derivation using Twitter feed, Python program and OAC (Oracle Analytics Cloud).

Step#1: Get feed from Twitter using Python

       Login to twitter link with your credentials https://developer.twitter.com/ and create an application

       Save the customerkey, customer secret, accesstoken, accesssecret keys available. Need this tokens to extract the feed.

       Install python 3 (or any suitable version) and Install pip and tweepy though command prompt

       Download get-pip.py file github.com  and  follow the steps)

       Run the command "python get-pip.py" through command prompt.

       "Python.exe -m pip"(to get list of commands)

       "Python.exe -m pip install tweepy" (command to install tweepy)

       A bit of coding now in Python J (Find a simple template code to get data from twitter)

       Run the script through command prompt as <<python file name>>. Then CSV twitter file will get downloaded to your desktop. Use that file in OAC to perform sentimental analysis.

Step#2: Sentiment Analysis using OAC

As part of OAC, DVCS has inbuilt capabilities to perform sentiment Analysis on textual data. To invoke sentimental functionality, add the twitter data set and create a data flow using the data set

In Oracle DV, sentiment analysis is implemented using Python. To invoke it add Analyze Sentiment node to the dataflow.

  §  Click on create Data set and select the twitter csv file and click on add

  §  Click on create data flow

  §  select the data set which you added (twitter excel) and click on Add

  §  For e.g. I took the twitter feed of product XXXXX and performed sentimental analysis on column "Tweet Text"

SentImage1.jpg










SentImage2.jpg












       Click on + sign and select "Analyze Sentiment"

SentImage3.jpg

















       In the Analyze Sentiment pane, Output section, give a column name to capture the emotion value. Rename the default column 'emotion' as needed.


SentImage4.jpg
















       In the Parameters section, choose the column with text content to analyze

       Click on select column and add the column from available data for e.g. Tweet Text

       After adding the analyze sentiment column we can see column with name as emotion and it indicates the "Positive"," Negative" or "Neutral"

       To add the column, click on Add step (+) and select the Add Columns

       Rename the column as required

       Give the Expression and click on Validate and select apply

       Now we can see the Count column added to the available data, click on save


SentImage5.jpg










SentImage6.jpg





















       Go to Home page and click on create and select the Project as shown

       Select the Dataflow which you created above and click on Add to project

       Select the attribute emotion and select the count measure and click on pick visualization (or you can drag drop the columns on right side pane accordingly)

SentImage7.jpg











SentImage8.jpg









SentImage9.jpg












       Below is the pie chart which is showing the positive, negative or neutral tweets as per the data available in the data set.

SentImage10.jpg

 

 









Python Code:

Using the below code snippet you could write a simple code to extract feed from twitter 
TwittercodeImg1.JPG




TwittercodeImg2.JPG

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles