Restaurant Recommendation System
By: Ansh Tiwari
Tags: Machine Learning, Data Science, Recommendation System

Restaurant recommendation system

Bangalore

1. Introduction

1.a. Description & Discussion of the Background

Bangalore, also known as Bengaluru (Kannada), is the Indian State of Karnataka’s capital. Bangalore is nicknamed the Garden City and was once called a Pensioner’s Paradise. Located on the Deccan Plateau in the south-eastern part of Karnataka, Bangalore is India’s third most populous city. There are several experts from across the world living in the city, thanks to the growing presence of Multi-National Companies.

As a large city and growing metropolis, Bangalore is home to many of India’s most well-recognized colleges and research institutions. Numerous public sector heavy industries, software companies, aerospace, telecommunications, and defense organizations are in the city. Bangalore is known as the Silicon Valley of India because of its position as the nation’s leading IT exporter. A demographically diverse city, Bangalore is a significant economic and cultural hub and the fastest-growing major metropolis in India.

Bangalore is a young and energetic city that is always ready to accept new challenges, so most startups are in Bangalore. Thus Bangalore city is the best option for this study.

1.b. Problem: Suppose a person travels and keep changing places very frequently. It is very hectic since they have to experience a completely new and different environment. In such a situation, food can be an essential factor in deciding how you rate your trips and recommend it to the people. Food can also attract people around the world to try it out if it were the best. In such scenarios, we need to find the right place, at a reasonable cost, to serve us in the best possible way. So few questions must be addressed, such as:

1.How many types of food are available in the restaurant?

2. Which is the nearest to me with a good rating?

3. How are many “similar” restaurants available near me?

4. Do the “similar” restaurants cost more? If so, what specialty do you have?

To address such a problem, I am assigned to build a system that can help recommend new places based on their rankings compared to the previous visits.

We will use our data science powers to generate a few most promising neighborhoods based on these criteria.

1.c. Interest: This will be interesting for anyone planning to find a new restaurant in Bangalore, but also will be interesting for those who are thinking to visit nearby places in the city because I will display the most popular venues in each of the 66 different locations in Bangalore, So maybe someone is planning to visit a mall or ice cream parlor, and from this blog, they can find where it is the best place for their purpose.

1.d. Data Description

Based on the definition of our problem, the factors that will influence our decision are:

Number of existing restaurants in the neighborhood (any type of restaurant)

Number of and distance to restaurants in the neighborhood, if any

The distance of neighborhoods from the city center.

We decided to use a regularly spaced grid of locations, centered around the city center, to define our neighborhoods.

Following data sources will be needed to extract/generate the required information:

Centers of candidate areas will be generated algorithmically and approximate addresses of centers of those areas will be obtained using Google Maps API reverse geocoding.

The number of restaurants and their type and location in every neighborhood will be obtained using the Foursquare API.

Coordinate of the center will be obtained using Google Maps API geocoding of well-known Bangalore location (Bangalore Palace).

2. Data Science Methodology

This analysis focuses on the Foundational Methodology for Data Science by John Rollins. However, it is not the only methodology that you will encounter in data science. For example, in data mining, the Cross-Industry Process for Data Mining (CRISP-DM) methodology is widely used.

The CRISP-DM methodology is a process aimed at increasing the use of data mining over a wide variety of business applications and industries. The intent is to take case-specific scenarios and general behaviors to make them domain neutral. CRISP-DM is comprised of six steps with an entity that has to implement in order to have a reasonable chance of success. The six steps are shown in the following diagram.

Business Understanding This stage is the most important because this is where the intention of the project is outlined. Foundational Methodology and CRISP-DM are aligned here. It requires communication and clarity. The difficulty here is that stakeholders have different objectives, biases, and modalities of relating information. They don’t all see the same things or in the same manner. Without a clear, concise, and complete perspective of what the project goals are resources will be needlessly expended. Data Understanding Data understanding relies on business understanding. Data is collected at this stage of the process. The understanding of what the business wants and needs will determine what data is collected, from what sources, and by what methods. CRISP-DM combines the stages of Data Requirements, Data Collection, and Data Understanding from the Foundational Methodology outline. Data Preparation Once the data has been collected, it must be transformed into a useable subset unless it is determined that more data is needed. Once a dataset is chosen, it must then be checked for questionable, missing, or ambiguous cases. Data Preparation is common to CRISP-DM and Foundational Methodology. Modeling Once prepared for use, the data must be expressed through whatever appropriate models, give meaningful insights, and hopefully new knowledge. This is the purpose of data mining: to create knowledge information that has meaning and utility. The use of models reveals patterns and structures within the data that provide insight into the features of interest. Models are selected on a portion of the data and adjustments are made if necessary. Model selection is an art and science. Both Foundational Methodology and CRISP-DM are required for the subsequent stage. Evaluation The selected model must be tested. This is usually done by having a pre-selected test, set to run the trained model on. This will allow you to see the effectiveness of the model on a set it sees as new. Results from this are used to determine the efficacy of the model and foreshadow its role in the next and final stage. Deployment In the deployment step, the model is used on new data outside of the scope of the dataset and by new stakeholders. The new interactions at this phase might reveal the new variables and needs for the dataset and model. These new challenges could initiate a revision of either business needs and actions, or the model and data, or both.

CRISP-DM is a highly flexible and cyclical model. Flexibility is required at each step along with communication to keep the project on track. At any of the six stages, it may be necessary to revisit an earlier stage and make changes. The key point of this process is that it’s cyclical; therefore, even at the finish, you are having another business understanding encounter to discuss the viability after deployment.

We web scraped the data from Wikipedia and built a data frame of each location’s postal code. To utilize the Foursquare location data, we need to get the latitude and the longitude coordinates of each area. We are leveraging the Google Maps Geocoding API to get the latitude and the longitude coordinates of each location as shown below:

As a database, I used the GitHub repository in my study. My master data has the main components Location, Pincode, Latitude, and Longitude information of the city.

I used folium library for visualizing geographic details of Bangalore and its locations superimposed on top shown below:

Now since we have the different data displayed into the map, now is time to start applying the Data Analysis and fetch the data in different Clusters with “Similar data”

3. Data munging and performing EDA

Data wrangling is one of the most important components in the data science workflow. It involves the processing of data in various formats like concatenating, grouping, merging, etc. for the purpose of getting them used with another set of data or for analyzing.

After munging the data we have removed rural areas and filtered out the top 66 locations based on population in the urban areas. The head of data after cleaning and its visualization in the map is shown below

We are adding two more features called Population and AverageIncome to our data frame as shown below:

In statistics, exploratory data analysis is an approach to analyzing data sets to summarize their main characteristics, often with visual methods. A statistical model can be used or not, but primarily EDA is for seeing what the data can tell us beyond the formal modeling or hypothesis testing task.

Now diving the locations under categories: ‘Central’, ‘Eastern’, ‘NorthEastern’,

‘Northern ’, ‘SouthEastern’, ‘Southern’, ‘SouthernSuburbs’, ‘Western’.

Now we have all the locations represented in the map with their latitude and longitude, We will make Foursquare API calls to fetch all the venues of limit as 100 surrounding that city with a radius of 500 meters, so we will be only focused in the center on the city because there is where usually people go for restaurants. Once we have every venue in the city, we will use One Hot Encoding to extract all the dummy variables that will be necessary to implement in the future the K means clustering. One hot encoding for letting us compare different venues based on some standard scale.

Getting the number of venues per neighborhood

From the above plot, we can see that Indiranagar has the most number of venues.

Now that we got the required information let’s do the model deployment. We are using the Elbow method to get the best value of K and from the plot below one can see the optimal value for the cluster is 5.

4. Inferential analysis:

The most important factors while building the recommender system were population and income. They are the most critical factor because they have a nonlinear relationship according to our dataset. It needed to make some inferential analysis to understand this nonlinear relationship. As the population increases, it does not necessarily mean that the average income of a neighborhood will also increase. It is right to most of the cases, but too many cases differ to follow this trend.

Similarly, a neighborhood with less number of people may not necessarily have a less average income. It is possible to have fewer people and more income and vice versa. This can be inferred from the following plot.

5. Discussion:

Since there was a nonlinear relationship between income and population, it can be concluded that we must always perform an inferential approach to find relationships among different sets of features. Also, during clustering, similar neighborhoods must be dumped into the right cluster. The following graph shows the clusters:

Another observation that we can make is that choosing several clustering could produce very diverse results. Some may be overfitted, or some may be under fitted. Hence the analysis of the number of clusters must be done. Refer elbow plot.

6. Result :

The result of the recommender system is that it produces a list of top restaurants and the most common venue item that the user can enjoy. During the runtime of the model, a simulation was done by taking ‘Whitefield’ as the neighborhood and then processed through our model to recommend neighborhoods with similar characters as that of ‘Whitefield.’ The following image shows the result:

8. Notebook :

7. Conclusion :

The recommender system is a system that considers factors such as population, income, and makes use of Foursquare API to determine nearby venues. It is a powerful data-driven model whose efficiency may decrease with more data, but accuracy will increase. It will help users to finish their hunger by providing the best recommendation to fulfill all their needs.