Location intelligence: the branch network optimization problem

Matteo Jucker Riva
5 min readJan 26, 2021

Location intelligence is the process of deriving meaningful insight from geo-spatial data to solve a business problem. These techniques become even more valuable when combined with ML for statistical analysis. In brief:

TLDR: I used geo-spatial data and Machine Learning to create a model of locations suitable for new branches of a prominent Swiss chain of supermarkets. You can see the results here and the code here

Introduction

This project addresses a particular problem for retail stores, called Branch Network Optimization. In this type of analysis, spatial data are used to determine optimal location for retail branches in order to improve spatial coverage and fill gaps in the branch network.

Source: Wikimedia commons

In this example we will try to identify spatial features that drive the location of Migros, one of the most prominent supermarket chains in Switzerland and feed the information to a machine learning model to identify additional promising locations for additional branches.

Disclaimer: I am not affiliated with MIGROS AG and this analysis was not prompted by them. All data used below is publicly available

Also, I will not show any code in this post. If you are interested in the code, please check the online repository

Input data

All GIS users know of Open Street Map, a global open source project that makes important spatial data available to all freely. OSM data is user submitted, so it might not be 100% correct and updated, but as you will see below, is a more than valid source for most uses. All data unless otherwise specified was downloaded from OSM using QGIS, the most known (and cool IMHO!) open source program for Geographic Information Systems (GIS).

The first step is to get a list of existing Migros (our target).

The following additional data was used to define spatial relationships (our predictors):

  • Main urban and suburban roads
  • Location of bus stops
  • Location of train stations
  • Population density per municipality (source: Federal Statistical Office)
  • Location of other supermarkets

Pre-processing and feature engineering

1. Transforming locations to densities.

Vector data such as the supermarkets or the roads in the maps above are discrete representations of information. As such, the number of operations that can be done on them is limited. To obtain a more useful format, we have to translate the information from points and lines into a series of aligned rasters; This means creating a square grid on top of the area of interest and assigning a value to each square based on the distance from the points of interest and their number. This operation can be done easily in QGIS using the Kernel Density Estimation tool, but analogous functions can be used directly in Python using libraries dedicated to spatial data (e.g. Rasterio or GDAL). This turns the map you see above into a much more usable array-like data structure.

Raster representation of train station density in 2d (left) and 3d (right)

2. Improving population data. Differently from the other predictors, population data was available only at the scale of municipality (see map above). This is not compatible with our 100 x 100 m grid, and could generate errors along the borders. To solve this, we can literally ask for help from the sky!

Indeed night time satellite images are a well known source of population density information (see here, here and here for example). A simple interpolation of the population by municipality with the brightness value of night-images allows us to improve the resolution of our population information.

Population density data before (left) and after interpolation (right)

3. Reducing data leakage. If you have some experience in ML and its pitfalls, you might have already spotted a common problem in my dataset: cross-correlation among predictors. Many of the spatial predictors I used such as bus stations, roads, train stations are strictly correlated with the population density. Thus, normalizing by the population density provides more useful information to the model.

Predicting Migros locations (the ML part)

Since this a classification problem, logistic regression is the natural go-to model and with reasons. After hyper-parameter optimization, the result is a decent 0.86 f1 score and a pretty good AUC score (0.91)

ROC curve ( a common metric of classification models performance) and the Area Under Curve value. Not bad!

Results

Coefficients and model interpretation. One of the advantages of Logistic Regression is its explainability. In other words we can easily interpret why the model assigns a certain value to a certain area and what is the behind-the-curtain logic of the results. By looking at the coefficients of the trained model we can derive the first 3 attributes that identify locations of current Migros branches:

  1. Close to bus stations
  2. Close to train stations
  3. In proximity of Denner supermarkets

New locations. Using the trained model, we can now calculate the favorability of the areas currently without a Migros. Naturally, many pixels immediately next to existing supermarket have a high score, but with a simple spatial selection in QGIS we can detect 57 areas with a model score above 0.5, that do not currently have a Migros branch according to our data

Want to see the results more in detail? Click here for the interactive map!

--

--