Thoughts Brewing Blog

AI Quick Tips 82: Use the built-in sentiment analysis

Written by Damien Griffin | Oct 16, 2024 12:00:00 PM

What is sentiment analysis?  It is understanding emotion and/or opinion.


There are a lot of ways that you could train and tune an AI chatbot model to do this.  If you are just getting started, though, a lot of the common chatbots are already trained to do basic sentiment analysis, so you don’t have to do any of the training yourself.


Here is a prompt that you can try to see if the one that you are using can recognize sentiment - 

Provide a sentiment analysis of the following statements 

This coffee is amazing

This tea is terrible

You are ugly

Meh


Here is what ChatGPT output -


If you happen to be more advanced and want to see the code used to get this, here it is -

from textblob import TextBlob

# Define the statements for sentiment analysis

statements = [
    "This coffee is amazing",
    "This tea is terrible",
    "You are ugly",
    "Meh"
]

# Perform sentiment analysis using TextBlob

sentiments = [(statement, TextBlob(statement).sentiment.polarity) for statement in statements]

sentiments

Note that ChatGPT runs this code in the background and provides it for reference or if you want to modify it.


There are all kinds of ways you can use sentiment analysis.  For example:

  • Review comments from social media posts
  • Analyze product/service reviews
  • Analyze customer service comments and prioritize the most negative for follow-up
  • Gauge interest on products on your website


So many others, but this is plenty to get you started.