Sitemap

Why Your Machine Learning Model Fails at Reading the Room

4 min readApr 27, 2026

--

Press enter or click to view image in full size
Stop doing vibe checks like it’s speed dating. Let MoodLens AI decode the feelings that are actually there. In this picture, Carlos Alcaraz 🎾 flashes his trademark infectious smile.

Have you ever looked at any modern AI emotion detector? You feed it an image of someone clearly experiencing sort of an existential crisis mixed with mild hunger pangs 😋, and the machine confidently outputs “Joy: 100%”. It’s quite embarrassing!

Traditional emotion classification models treat feelings like an MCQ quiz 📝 with only one right answer. They force the AI into picking one option. If someone forces a smile but has expressionless eyes, a standard algorithm basically goes haywire. It picks “Happy” and calls it a day. This is known as hard-label classification. TBH, it’s terrible for reading human emotions.

Press enter or click to view image in full size
Kevin O’Leary doing a not-so-wonderful act of squishing a cockroach. For most people, this act would feel disgusting, but for Kevin, the predominant emotion is “joy.”

Humans don’t work like that. If you see a cockroach 🪳 on your keyboard (BTW, Kevin O’Leary, aka Mr Wonderful, would squish the cockroach instantly in a not-so-wonderful way), you’re probably feeling fear. You’re probably also feeling disgust. Maybe a tiny bit of surprise. Our emotions are messy. They’re probability distributions. Ten different people looking at the exact same image will likely report ten slightly different emotional reads.

This completely predictable failure of standard machine learning models brings me to my latest project. Enter MoodLens AI.

The Problem With Putting Feelings in a Box

I got tired of systems that try to simplify human psychology into six binary checkboxes. I built this MoodLens AI framework to stop forcing single labels onto complex facial expressions.

The Emotion6 dataset was the perfect starting point for this. It contains nearly two thousand images annotated with emotion probability distributions. These annotations come from multiple human reviewers. The dataset captures the reality of emotional ambiguity perfectly.

Look at how the frontend interface handles this complexity:

Press enter or click to view image in full size
A sleek Streamlit interface showing the model ready to analyze some messy human feelings.

The Secret Sauce (Soft-Label Learning)

Instead of using a standard Cross-Entropy loss function that demands absolute certainty, MoodLens AI uses a metric known as KL Divergence. This is the crucial feature that completely changes the game. KL Divergence teaches the model to predict the full probability distribution. The model can actually say, “I am 60% sure this is fear, but there is a 30% chance it’s disgust.”

This is called soft-label learning. It results in confidence calibration. If an image is genuinely confusing, the model acts confused. It lowers its confidence scores appropriately instead of just guessing wildly. It aligns significantly better with actual human perception.

I experimented with a few architectures, but a fine-tuned ResNet-50 proved to be the undisputed winner for this task.

Seeing It In Action

Let me show you what happens when we feed some real data into the application.

Get Arjun K’s stories in your inbox

Join Medium for free to get updates from this writer.

Look at this prediction for Fear 🙀. The model doesn’t just blindly stamp a label on it. It gives us a beautiful breakdown of the probability distribution.

Press enter or click to view image in full size
The model is accurately identifying fear 🙀while acknowledging other emotional noise.

And here is how it handles disgust 🤢. Notice how the probability bars give you a clear, visual representation of the model’s thought process.

Press enter or click to view image in full size
Disgust predicted with high confidence.

The framework clearly differentiates between Sadness😿 and Joy🐱, but it still maintains the nuanced probabilities for the secondary emotions.

Press enter or click to view image in full size
Predicting sadness 😿 with a very natural distribution curve.
Press enter or click to view image in full size
Spotting joy 😺without completely erasing the possibility of surprise.

The Numbers Don’t Lie

Visuals are great, but the metrics prove that the soft-label approach actually works. My ResNet-50 implementation hit a 61.62% Top-1 Accuracy. That comes incredibly close to the original Research paper’s baseline of 64.72%.

Here is a quick look at the primary results:

Press enter or click to view image in full size
Visual breakdown of the model’s performance.

When we break it down by specific emotions, the Pearson correlation gives us even more insight into what the model handles well and what confuses it.

Press enter or click to view image in full size
A deep dive into how specific emotions are tracking.

Experience the Magic (Walkthrough)

If you want to see the system in action without downloading a single dependency, check out the full walkthrough here:

What’s Next For MoodLens?

This framework proves that we can build AI that respects the nuance of human emotion. A FastAPI backend powers the engine, and the Streamlit frontend makes it entirely interactive.

I plan to integrate MLflow and DagsHub tracking to rigorously monitor future model iterations. I also want to containerize the whole application using Docker. That will simplify cloud deployment.

Machine learning is evolving, and it’s time our emotion classification models evolve with it. Let the machines finally understand that sometimes, you’re just a complicated mix of surprised and disgusted😅.

Laugh away your problems! 😽

That’s it for today, guys! Hasta la vista! Adiós, amigos! 👋🏼

--

--

Arjun K
Arjun K

Written by Arjun K

Data Scientist & ML Engineer exploring ML, deep learning & Gen AI through practical projects. I write about AI, data, books & the occasional absurdity of life.