Customized NLP model

The objective of this project was to overcome the constraints of conventional NLP models when analyzing sentiment for contrasting options, specifically by exploring the limitations of such models in understanding sentiments related to different choices.

Objective

Our client, a notable figure in the dairy industry aiming to highlight the benefits of real milk, was interested in analyzing the sentiment of those engaging with our ad campaign on social media. Using mainstream NLP tools, we found that sentiments were often misclassified for our frame of reference. For instance, a comment reading, “This recipe looks great, but I would substitute for almond milk!” would be classified as positive but is actually negative given the objective of the client.In turn, overall positive sentiment was artificially inflated, leading to misguided campaign strategy.

Problem

I created a training dataset using a collection of comments scraped from various social media channels related to cooking, baking, farming, diet, health, etc. and filtered for mentions of milk and adjacent phrases. With an idea of the language commonly used, I wrote additional sentences with the help of chatGPT to create a more robust dataset.

I then wrote a code utilizing Tensorflow to create a customized NLP sentiment analyzer. After training, the model was applied to a collection of comments responding to our campaign material. To visualize this, I added code to create word clouds with the resulting positive and negative sentiments. Read my code here!

Solution

“Positive” Sentiment

“Negative” Sentiment

Fig 1. The positive sentiment word cloud displays expected verbiage such as “love” and “good”. Dissecting the negative sentiment word cloud is slightly more complicated however. Obvious negative sentiment is still represented (see “bad”, “cancer”, “disease”) but we also see the contextually “negative” sentiment expressed through words such as “oat”, “almond”, “alternative”, “lactose”, and “intolerance”. The word cloud also unveils a latent undercurrent of sentiment towards dairy milk, encompassing concerns related to the well-being of animals and the ecological impact on our planet.