Study on Movie Recommendation Based on Emotion in Python

Introduction

Recommendation systems are widely used in platforms like Netflix and Amazon Prime to suggest content based on user preferences. One interesting approach is emotion-based movie recommendation, where movies are suggested based on the user's current mood or emotion.

Click here if you're learning Python projects, a beginner-friendly Python book can help you build strong fundamentals.

In this article, you will learn how to build a simple movie recommendation system in Python that suggests movies based on emotions.

Python program for emotion-based movie recommendation system example

What is Emotion-Based Recommendation?

Emotion-based recommendation is a technique where the system identifies the user’s emotional state (such as happy, sad, angry, or relaxed) and suggests content accordingly.

For example:

  • Happy → Comedy, Feel-good movies

  • Sad → Motivational or uplifting movies

  • Angry → Action movies

  • Relaxed → Romantic or light drama

Approach to Build the System

We will follow these steps:

  • Define emotions

  • Create a movie dataset

  • Map emotions to movie categories

  • Recommend movies based on user input

Python Program

# Movie dataset based on emotions
movies = {
    "happy": ["3 Idiots", "Zindagi Na Milegi Dobara", "The Intern"],
    "sad": ["The Pursuit of Happyness", "Rocky", "Forrest Gump"],
    "angry": ["Mad Max: Fury Road", "John Wick", "Gladiator"],
    "relaxed": ["Before Sunrise", "The Notebook", "La La Land"]
}

# Function to recommend movies
def recommend_movie(emotion):
    emotion = emotion.lower()
    if emotion in movies:
        return movies[emotion]
    else:
        return ["No recommendations available for this emotion."]

# User input
user_emotion = input("Enter your current emotion (happy/sad/angry/relaxed): ")

# Get recommendations
recommended = recommend_movie(user_emotion)

print("\nRecommended Movies:")
for movie in recommended:
    print("-", movie)

Sample Output

Enter your current emotion (happy/sad/angry/relaxed): happy

Recommended Movies:

  • 3 Idiots

  • Zindagi Na Milegi Dobara

  • The Intern

Explanation of the Code

  • A dictionary is used to map emotions to movie lists

  • The function checks the user’s emotion

  • It returns a list of movies based on that emotion

  • If emotion is not found, it returns a default message

How to Improve This System

  • Use a larger movie dataset

  • Integrate sentiment analysis to detect emotion automatically

  • Connect with APIs like TMDB for real-time data

  • Build a GUI using Tkinter or a web app using Flask

Why This Project is Useful

  • Helps understand recommendation systems

  • Improves Python programming skills

  • Introduces basic AI concepts

  • Can be extended into real-world applications

Conclusion

Emotion-based movie recommendation is a simple yet powerful concept. With basic Python knowledge, you can build a system that personalizes content based on mood. This project is a great starting point for beginners interested in AI and machine learning.

Comments