How to create a simple movie recommendation System

Introduction

This part of the Content Editor Internship ”

“Every time I go to a movie, it’s magical, no matter what the movie is about. – Steven Spielberg

Everyone loves movies regardless of age, gender, race, color, or location. We are all in some way connected to each other in this amazing way. But most interesting is the fact that our choices and combinations are different in terms of our preferences. Some people like movies that are specific to the genre, be it entertaining, romantic, or sci-fi, while others focus on the main characters and directors. Considering all of that, it is incredibly difficult to make a movie a reality and say that everyone can love it. But with all that being said, it is still clear that the same films are popular in some parts of the community.

So this is where we as data scientists come in and extract the juice from all behavioral patterns not only for the audience but also for the movies themselves. So without wasting any time, let’s jump right in and out of the game.

What is the Recommendation Plan?

Simply put, the Recommendation Program is a filtering program whose primary purpose is to predict the user’s “rating” or “preferences” for a particular item or item. In our case, this domain-specific object is a movie, so the main focus of our recommendation system is to filter and predict only those movies that the user may prefer to provide certain data about the user himself.

Let’s create Dataset for the movies

dataset = {
    "action" : ["matrix","batman","superman","dabang","avengers","thor",
                "hulk","krrish","ironman",'kgf'],
    "comedy" : ["the mask","dhamaal","bala","housefull","golmaal",
                "hera pheri","golmaal 2","dhamaal 2","hera pheri 2"],
    "drama" : ["dabang","krrish","hera pheri","bala","kahani","batla house",
               "kgf","zero","sultan"],
    "thriller" : ["kahani","kgf","batla house","madras cafe","uri",
                  "raw","lucy","the ring","oculus"],
    "horror" : ["oculus","the ring","it","the ring 2","evil dead",
                "conjuring","conjuring 2","bhootnath","aatma"]
}

Assume that some user has watched the following movies

user = {"kgf", "zero", "superman", "batman", "evil dead", "sultan",
          "golmaal", "krrish", "bala"}

In this post we will be creating a movie recommendation system using Jaccard’s distance.

#scores = {"action":0.33, "comedy":20...} using jaccard distance formula
#find the genre with max score
#recommend movies from that genre which has max score and user has not watched those movies yet...
scores = {}
for item in dataset:
    movies = set(dataset[item])
    intersection = user.intersection(movies)
    union = user.union(movies)
    dist = len(intersection) / len(union)
    scores[item] = round(dist,2)

print(scores)
category = max(scores, key=scores.get)

recommendedMovies = set(dataset[category]) - user
print(recommendedMovies)

This program prints the movies recommended by the system and user has not watched it yet.

Important Notice for college students

If you’re a college student and have skills in programming languages, Want to earn through blogging? Mail us at geekycomail@gmail.com

For more Programming related blogs Visit Us Geekycodes. Follow us on Instagram.

Leave a Reply

%d bloggers like this: