Sentiment needs to be summarized into categories for better analysis and comprehension. Summarize the sentiments for movie reviews and plot a pie chart for the summary.
- [Instructor] In this video, we will summarize the sentiments we discovered earlier. The sentiments variable contains the sentiments by each review in the corpus. We will classify the sentiment to be either positive, negative or neutral. First, we convert the sentiments vector into a DataFrame by using the setDF function. Next, we create a function called get_sentiment_class that will return the sentiment class when provided with a sentiment score. For all the sentiment values which are less than minus .3, it will classify as negative. All values greater than plus .3 are classified as positive if the value is between minus .3 and plus .3, the sentiment is considered neutral. This is what this function would compute. Then, using the sApply function, we iterate through all the sentiment scores in the DataFrame and call the get_sentiment_class function for each of them. We store the results in a new sentiment_class column in the same DataFrame. We then print the resulting sentiment along with the sentiment score. Let's execute this code and review the results. In the results, we see that the sentiment score has been converted to an equivalent sentiment_class. Next, we will plot the sentiment_class in a pie chart. For this, we first use the count function to summarize the data by sentiment_class. Then we draw a pie chart using the summary DataFrame. Let's execute this code and review the results. This approach allows us to analyze sentiments, summarize and present the results. In the next video, we will analyze emotions.
Released
10/1/2019- Creating a word cloud
- Analyzing sentiment
- Extracting emotions from text
- Clustering similar entities based on text
- Using classification for supervised learning
- Recommending items to users based on text data analytics
Share this video
Embed this video
Video: Summarizing sentiment