Clustering population in London to find a suitable location for ethnic restaurant
By: Balint Hudecz
Tags: Kmeans, Population, Data Science, Clustering, Data Visualization

As a digital communication professional, data science is not new to me, but I have never systematically learned it, just picked up the necessary skills on the job. So one of my COVID-19 lockdown commitments was to look into data science and machine learning in a bit more structured way. Google must have guessed my intention as I got a few targeted ads — which led me to IBM’s Data Science Program on Coursera. This post is not a review, it’s about my capstone project.

The idea was to find a suitable location for a traditional ethnic restaurant in London using exploratory data analysis and machine learning. It made sense to look into London’s Chinese population — if you live in the city you must have heard of the Chinese district, possibly the worst place to open a new traditional restaurant, right? But then where else, are there other parts of the city where the concentration of Chinese people* is high and there aren’t many popular Chinese restaurants?

*in the census data people are classified according to their own perceived ethnic group and cultural background

To get things started we need quite a few datasets to work with. Most of the files can be found in my repo except the data files as those are quite big — but check the notebook for the links:

London’s census data (2011 is the latest) broken down to Middle Layer Super Output Areas (MSOAs) level

level Population weighted centroids for MSOAs

Land area of MSOAs

Shapefiles for MSOAs

Foursquare to get the most popular venue types

Before jumping in…

If you are using any APIs, database connections, or else in your code, it’s a really good practice not to include the credentials in the files that you share, upload to GitHub, or to any other code sharing platform. Personally, I like to use dotenv for Python-related projects — it’s easy to set up: create a .env file in your root folder, store your credentials there, and then add to the beginning of your Jupyter Notebook the following:

%load_ext dotenv

%dotenv # get your key client_id = %env CLIENT_ID

cliend_secret = %env CLIENT_SECRET

Initial exploratory data analysis

I won’t include here the data wrangling that I did for the combined dataframe of the census, centroids, and land areas datasets — please check the repo if you are interested. I ended up with the following table:

The MSOAs name and total columns are in the table for reference only, we are not going to use those in our analysis. The Chinese population column contains the combined population of all Chinese related ethnic groups, while the latitude and longitude columns are the population-weighted centroids of the MSOAs.

The idea is to find out which neighborhoods have a higher Chinese population, and then explore the most popular restaurant types in those areas. The Office of National Statistics works with different kinds of output areas: Middle Layer Super Output Areas (MSOAs) is a sensible choice as it provides the desired granularity to define our own ‘neighborhoods’. Using the MSOAs, folium’s choropleth map showing the Chinese population will look like the following.