Coffee Shop Site Selection in Paris using Clustering Algorithm
By: Chayeb Khaled
Tags: Paris, Data Science, Clustering, K Means, Machine Learning

B. Methodology

1. Acquiring Data

In this study, we have three data resources which permit to build all the datasets and run the required analyses.

Geographic Data

From the open plateforme of public data in France, I downloaded two json files to build Paris boroughs and neighborhoods dataframes.

The figure below shows 5 neighborhoods in Paris and their features: PostalCode, Borough, Borough Surface, Neighborhood, Latitude, Longitude.

Paris Neighborhood Dataframe

Paris consists of 20 boroughs and each borough is divided into 4 neighborhoods. In total, we have 80 neighborhoods. The figure below shows a map of Paris boroughs and neighborhoods.

Paris Map

Venue Data

Foursquare API is used to get venues at each neighborhood. The figure hereafter shows the corresponding dataframe.

Paris Venues

Demographic Data

Now that we built neighborhood and venue dataframes, we will focus on getting demographic data from INSEE website:

- Median household income

- Population density

- Employee base

- Employment status

INSEE website provides data per borough. Therefore, I will scrape data for each borough, then, assign borough values to the neighborhoods composing it. Scraping process was performed using BeautifulSoup python library.

The figure below shows the demographic dataframe.

Paris Demographic Data per Borough

The Column Preferred Section Employees contains the number of jobs in industry, administrative and service sectors at each borough. The more employees in these sectors the more we can consider that the borough is an employee base.

2. Exploring and Data Processing

Paris Coffee Shops and Competitiveness

As we are interested only by coffee shops, we need to extract from Paris venues those shops based on the category. Coffee shops belong to the categories Café or Coffee Shop.

Paris Coffee Shops per Neighborhood

The number of coffee shops is an important information to check whether the neighborhood includes many competitors. Based on this data, we can set the competitiveness level at each neighborhood. To do that, let’s look at the distribution of coffee shops shown in the figure below.

Neighborhood Coffee Shops Distribution

Based on the bar chart above, number of coffee shops per neighborhood, we can classify neighborhoods in 3 categories.

- low competitiveness: number of coffee shops less than 2

- medium competitiveness: number of coffee shops is between 2 and 4

- high competitiveness: number of coffee shops greater than 4

Now, the neighborhood dataframe is having a new column to label competitiveness level as shown in the figure below.

Neighborhood Data Frame — Competitiveness

Preferred Sector Employee Density

If we consider all borough demographic data, except Preferred Sector Employees, we can apply them to the neighborhoods forming the borough because they are normalized with respect to surface or population. I calculated Preferred Sector Employee Density to be able to use it for the neighborhoods.

Preferred Sector Employee Density=Preferred Sector Employees/Borough Surface

The final neighborhood dataframe will look as the figure below.

Paris Neighborhood DataFrame — Competitiveness and Demographic Data

3. Cluster Paris Neighborhoods

Now that I have the final dataset, I can proceed to clustering Paris neighborhoods in order to recommend, to a business starter, a neighborhood where it is better to open his own coffee shop.

Before running clustering algorithm, I transformed Competitiveness column using the one hot encoding function in order to obtain numerical data. Then, I used StandardScaler to normalize all the features.

I used k-means algorithm to segment Paris neighborhoods. To choose the optimal k value, I applied the elbow method as shown in the figure below.

KMeans Algorithm — Elbow Method

We can see on the plot that the mean distance drops down at the k value 5 and gives the graph an elbow shape. Therefore, we can conclude that our optimal value is: k = 5.