Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: [email protected]
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-François Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Take our 85+ lesson From Beginner to Advanced LLM Developer Certification: From choosing a project to deploying a working product this is the most comprehensive and practical LLM course out there!

Publication

Practical Implementation of Content-Based Recommendation System
Latest

Practical Implementation of Content-Based Recommendation System

Last Updated on January 7, 2023 by Editorial Team

Author(s): Gowtham S R

Originally published on Towards AI the World’s Leading AI and Technology News and Media Company. If you are building an AI-related product or service, we invite you to consider becoming an AI sponsor. At Towards AI, we help scale AI and technology startups. Let us help you unleash your technology to the masses.

A complete end-to-end Content-based recommendation system that recommends similar movies based on the user’sΒ input.

Image from Unsplash uploaded by KristsΒ Luhaers

What is a recommendation system?

Whenever we visit a shopping mall to buy a new pair of shoes or clothes, we find a dedicated person who helps us with the kind of products we should buy based on our preferences and makes our job simpler. In simple words, he is a recommendation system. But in this modern world, everything is online, and there is so much content on the internet, there are crores of videos on Youtube and crores of products on Amazon, which makes it difficult for the user to choose. There comes the recommendation system, which makes the user’s life simple by recommending the next video to watch or a similar product toΒ buy.

A recommendation system is a piece of code that is intelligent enough to understand the user’s preferences and recommend things based on his/her interest, the goal is to increase profitability. For Eg, Youtube and NetFlix want you to spend more time on their platform, so they recommend the videos based on the user’s preferences. Amazon wants you to buy products from their website so that they can make moreΒ profit.

What are the different types of Recommendation systems?

Image byΒ author

Popularity-based: Recommending the top products from their website to every user. This method will not consider the user’s interest. E.g., the Trending section on Youtube, IMDB top 250Β movies.

Content-based:

Image byΒ author

This is based on the similarity between the products. E.g., If a user has watched a movie and liked it, he may like to watch similar movies in the future. This can be based on the genre, actor, actress, or director.

Collaborative filtering:

Image byΒ author

This is based on the similarity of users. E.g., If person A and B had watched and liked the movie M, next if person A watched the movie Z and liked it, we can recommend the movie Z to person B since A and B are similarΒ users.

If you are keen to know how we can build a popularity-based and collaborative-filtering-based recommendation system, consider reading the belowΒ blog.

A Complete end to end Machine Learning based Recommendation Project

Hybrid filtering: This makes use of all or some of the above-mentioned methods to form a hybridΒ model.

Content-based Movie Recommendation System:

Let us look at how we can build a content-based book recommendation system. Below is the image of the final model that we are going to build for thisΒ project.

Image byΒ author

Following are the steps we will be performing.

  • Merge the data frames β€˜movies’ and β€˜credits’ to get the final dataΒ frame.
  • Consider only the requiredΒ columns.
  • working on the columnβ€Šβ€”β€Šgenres:

The column β€˜genres’ is the list of dictionaries, it has both keys and values, but we need only the genre values, so let us make a function to get only the requiredΒ data.

The β€˜genres’ column now contains only the requiredΒ data.

  • Let us apply the same function to column β€˜keywords.’
  • Let us modify the above function to get only the first 3 castΒ names.
  • Let us get the director’s name from the column β€˜crew’ by modifying the above function.
  • Let us convert the column β€˜overview’ from string toΒ list
  • We need to modify the names of the crew and cast members in such a way that there should not be any space between the names because when we convert words into vectors, our machine learning model will get impacted. E.g., James Cameron should be converted to β€˜JamesCameron’ and Johnny Depp to be converted to JohnnyDepp and Science Fiction to be converted to ScienceFiction.
  • Let us make a new column called tags by concatenating the features β€˜keywords’, β€˜overview’, β€˜genres’, β€˜cast’, andΒ β€˜crew’.
  • Let us make a new data frame new_df by taking only the features β€˜movie_id’, β€˜title’, andΒ β€˜tags’.
  • Let us convert the feature β€˜tags’ from a list to aΒ string.
  • Convert the feature β€˜tags’ into lowercase.
  • Apply stemming for converting the words into their baseΒ forms.
  • Now let us convert the tags into a Bag of words while removing all the stop words, and now the movie vectors will be ready. Each movie is a vector with 5000 dimensions.
  • Let us calculate the similarity score between each movieΒ vector.
  • Let us make a function that takes a movie name as the input and recommends 5 movies based on the similarity scores.

Take a look at some of the recommendations from theΒ model.

  • Model Deployment: Let's make use of the β€˜streamlit’ library to make a simple GUI and deploy theΒ model.

We have successfully completed the front end of the app, and you can deploy it to any of the cloud platforms. Take a look at some of the recommendations below.

Image byΒ author
Image byΒ author
Image byΒ author

We have successfully completed all the steps, and our model is ready. You can try and build a similar model. The complete code can be found on my GithubΒ page.


Practical Implementation of Content-Based Recommendation System was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Join thousands of data leaders on the AI newsletter. It’s free, we don’t spam, and we never share your email address. Keep up to date with the latest work in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.

Published via Towards AI

Feedback ↓