In this article, I will introduce you to a machine learning project on Restaurant Recommendation System with Python programming language. There is an extended class of applications that involve predicting user responses to a variety of options. Such a system is called a recommender system.
How the Restaurant Recommendation System Works?
The rapid growth in data collection has led to a new era of a data-driven world. Data is used to create more efficient systems and that’s where recommender systems come in.
Recommendation systems are a type of information filtering systems because they improve the quality of search results and provide elements that are more relevant to the search item or that are related to the search history of the user.
These are active information filtering systems that personalize the information provided to a user based on their interests, relevance of the information, etc. Recommendation systems are widely used to recommend movies, items, restaurants, places to visit, items to buy, etc.
There are two types of recommendation systems:
- Content-based filtering
- Collaborative filtering
A Restaurant recommendation system uses content-based filtering. This method only uses information about the description and attributes of items that users have previously consumed to model user preferences.
In other words, these algorithms try to recommend things similar to what a user liked in the past. The dataset I’ll be using here consists of restaurants in Bangalore, India, collected from Zomato. You can download the dataset from here.
To create the Restaurant recommendation system, I will create a content-based recommendation system where when I enter the name of a restaurant, the Restaurant recommendation system will look at reviews from other restaurants, and System will recommend us to the other restaurants with similar reviews and sort them from the top-rated.
Machine Learning Project on Restaurant Recommendation System with Python
I will start the task of Restaurant Recommendation System by importing the necessary Python Libraries:
Now, I will load and read the dataset:
zomato_real=pd.read_csv("zomato.csv") zomato_real.head() # prints the first 5 rows of the dataset
Now the next step is data cleaning and feature engineering for this step we need to do a lot of stuff with the data such as:
- Deleting Unnecessary Columns
- Removing the Duplicates
- Remove the NaN values from the dataset
- Changing the column names
- Data Transformations
- Data Cleaning
- Adjust the column names
Now, let’s perform all the above steps in our data:
Now the next step is to perform some text preprocessing steps which include:
- Lower casing
- Removal of Punctuations
- Removal of Stopwords
- Removal of URLs
- Spelling correction
Now let’s perform the above text preprocessing steps on the data:
|12110||rated 20 ratedn piece shit customer service wo…||Ice Cream, Desserts|
|25865||rated 10 ratedn ordered chicken fried rice chi…||Bengali, North Indian, Chinese|
|555||rated 40 ratedn perfect place burger coke frie…||Burger, Fast Food|
|14033||rated 40 ratedn place needs introduction locat…||Bakery, Cafe, Italian, Desserts|
|37162||rated 50 ratedn located city market cant miss …||Healthy Food, Juices|
TF-IDF (Term Frequency-Inverse Document Frequency) vectors for each document. This will give you a matrix where each column represents a word in the general vocabulary (all words that appear in at least one document) and each column represents a restaurant, as before.
TF-IDF is the statistical method of assessing the meaning of a word in a given document. Now, I will use the TF-IDF vectorization on the dataset:
Now the last step for creating a Restaurant Recommendation System is to write a function that will recommend restaurants:
|Cinnamon||North Indian, Chinese, Biryani||3.62||550.0|
|Prasiddhi Food Corner||Fast Food, North Indian, South Indian||3.45||200.0|
|Shrusti Coffee||Cafe, South Indian||3.45||150.0|
|Shanthi Sagar||South Indian, North Indian, Chinese||3.44||400.0|
|Shanthi Sagar||South Indian, North Indian, Chinese, Juices||3.44||250.0|
|Mayura Sagar||Chinese, North Indian, South Indian||3.32||250.0|
|Container Coffee||South Indian||3.11||200.0|
As as you can see that we got a fairly good output. So, I hope you liked this article on Machine Learning project on Restaurant Recommendation system with Python programming language. Feel free to ask your valuable questions in the comments section below.