back to portfolio

mohit / sentiment analysis app

Sentiment Analysis App

An LSTM that spots sarcasm.

You run a batch of social media posts through a sentiment classifier. "Great, another Monday" comes back positive. "Oh brilliant, the wifi died again" comes back positive too. Your dashboard now says people are delighted, and they are furious.

Most sentiment tools sort text into positive, negative or neutral and stop there. Sarcasm lands in the wrong bucket, and nobody notices until the numbers look odd.

I wanted a model that treats sarcasm as its own label, so I built one.

The app takes a piece of text and returns one of four labels: positive, negative, neutral or sarcastic. An LSTM network reads the text in sequence, which lets it pick up word order and tone that a simple word count misses. A FastAPI service wraps the model, so you send text in and get a label back.

Think of it as a sentiment classifier with a fourth option for the posts that say one thing and mean another.

What you can do

  • Classify text as positive, negative, neutral or sarcastic.
  • Send text to a FastAPI endpoint and read the label from the response.
  • Try it from a simple web page without writing any code.
  • Open the notebook to see how the model was trained and tested.
  • Train on your own data by swapping in your own CSV files.
  • Deploy it with the included Procfile.

Sarcasm is the hardest label to get right and the one where the model slips most.

What it doesn't do

It doesn't call a third-party AI service. The trained model, tokeniser and label encoder sit in the repo, and the API loads them directly. No account. No API key.

Built with Python, TensorFlow, LSTM, FastAPI and Scikit-learn. Trained on a social media sentiment dataset.