# Where Will Java House Open the Next Branch

*Originally published in April 2017*

Let’s play a game — the game goes, where would you place the location pin for the next Java outlet in Nairobi? The restaurant chain has been on a rapid expansion in the past two years and there are no signs of stopping the momentum. This week, the company opened a new outlet at Shell Petrol Station in Parklands thereby increasing the density of their outlets in the Westlands region. It is worth noting that a new Java House outlet costs about Kshs 50 million to set up — therefore, the decision on location has to be well calculated. Let’s begin our quest by understanding the current dispersion of Java outlets in the city.

As anticipated, the density of outlets is highest in the Central Business District and most other outlets spread to the west of the city. Using the current restaurants as reference points, we can begin our task of predicting where the next outlet would be located. To get started, we will use an interesting mathematical algorithm known as a Voronoi Diagram. Given a set of geographical locations, the Voronoi partitioning algorithm finds optimal boundaries that define the sphere of influence of a location.

For example, when rival gangs operate in the same territory, given the ‘headquarters’ of each gang, then the Voronoi algorithm would define the optimal boundaries of the gangs and essentially minimise conflict. Thinking of each Java outlet as a gang that needs to control territory, then we can build a visualisation of their area of influence as shown below.

[caption id=”attachment_23330" align=”aligncenter” width=”712"]

Locations of Java House restaurants in Nairobi[/caption]

As anticipated, the density of outlets is highest in the Central Business District and most other outlets spread to the west of the city. Using the current restaurants as reference points, we can begin our task of predicting where the next outlet would be located. To get started, we will use an interesting mathematical algorithm known as a Voronoi Diagram. Given a set of geographical locations, the Voronoi partitioning algorithm finds optimal boundaries that define the sphere of influence of a location.

For example, when rival gangs operate in the same territory, given the ‘headquarters’ of each gang, then the Voronoi algorithm would define the optimal boundaries of the gangs and essentially minimise conflict. Thinking of each Java outlet as a gang that needs to control territory, then we can build a visualisation of their area of influence as shown below.

[caption id=”attachment_23346" align=”aligncenter” width=”500"]

We can already see that some outlets control very large areas whilst others are way too small. From a strategy point of view, it would be logical to find the largest territory and split it for the new outlet. However, the inverse presents the best strategy. If a territory was split before it means that’s an area where they have influence and more customers. The more it is split, the high the chance of success until a critical threshold is met where the outlets will be too many to be viable. A good example is Java Mama Ngina Street and Java City Hall which are less than 50 meters apart.

Back to our prediction problem. Now, we have another data point to use — sector. Initially, the first Java restaurant in Adam’s Arcade had only one sector — the whole of Nairobi. As more outlets were opened, the sector was split and the other sub-sectors formed. Using the logic built in the previous paragraph, we can use conditional probability to measure the likelihood of a sector being split given it was formed from another split sector.

Conditional probability is used to model events that rely on pre-conditions. For example, what’s the probability that it would rain if the clouds are dark and it’s August? — Pretty high. The pre-conditions can be as many observable variables *(the more, the merrier — improves accuracy).*

These can form a very large chain such as, what’s the probability of someone winning a presidential election if they are an incumbent president, very rich, come from the largest tribe, studied abroad, is charismatic, likeable, have a powerful deputy et cetera. Using the same logic, we can build a chain of probabilities measuring the chance of a sector being split given it came from a sector that was split before which was in turn split before…. The diagram below shows a sample of the process evaluating the conditional dependency of sectors *(locations)*

Finally, we visualise the dependencies using a Bayesian network which creates connections that have the highest dependencies. In the network, if we track the path(s) with most nodes (locations), then we will find the sector that has the highest number of sub-divisions hence of great interest to Java. The diagram below shows the resultant Bayesian Network.

From the diagram, the first location with the highest probability of getting a new outlet is between Uniafric House (CBD) and TRM Mall. For this region, the best candidate locations are Mobil Plaza in Muthaiga and Ruaraka. Two other locations that scored highly were; between Aero Club (Langata) and Prestige Plaza, and between Embassy House (CBD) and Phoenix House (CBD) — along Uhuru Highway.