Selecting a Location for your Restaurant with Data Analysis

Selecting a Location for your Restaurant with Data Analysis

Lagos_AB_Responsive_1280x520.jpg

INTRODUCTION

Most start-ups find choosing a location for their businesses difficult. Even after streamlining to a populated City or State, narrowing down to a specific Local Government Area is usually a problem. I am thus developing a system that analyses the different areas in a State and suggests to an Entrepreneur or Organisation the best areas to set-up in. My selected location Lagos is the financial capital of Nigeria and has the highest population density in the country. This makes it a place to be for restaurants.

For this project, the target audience are restaurants just starting up or planning to open a branch in a new city. I also assume that these restaurants target employees of organizations as customers and thus aims to provide feedback that will help in pinpointing areas densely populated with Offices and Organizations.

DATA

Getting data for this project was a nigh herculean task but I was successful. I was able to obtain this json file from the HUMANITARIAN DATA EXCHANGE JSON REPOSITORY. It contains the geographical details of Local Government Areas in Nigeria and I extracted those of Lagos from it.

I also used the Foursquare location data to get information about the offices in the different areas and their corresponding categories.

METHODOLOGY

To obtain data about the Local Government Areas (which will be called LGAs subsequently) in Lagos, I installed the geopandas library. With this, I was able to read the Nigerian LGAs .json file into a geopandas data frame. I then filtered the datapoints pertaining to Lagos LGAs into a new data frame and wrote this into a .geojson file for later use. From this same dataframe, I extracted the feature showing the LGAs in Lagos into a new data frame. I then used the geopy module to obtain the latitude and longitude of these LGAs. Whilst doing this, an AttributeError was raised. I thus included a try block to view the LGAs causing the errors. With this I identified and corrected 2 LGAs that were wrongly named.

for i in lagos_df['NAME_2']:
    address = f'{i}, Lagos'
    geolocator = Nominatim(user_agent="lag_explorer")
    location = geolocator.geocode(address)
    try:
        coordinates['latitude'].append(location.latitude)
        coordinates['longitude'].append(location.longitude)
        coordinates['LGA'].append(i)
    except AttributeError:
        print(f'{i} is a problem')

I created 2 functions to help with extracting foursquare location data. The first was named get_category_type. This takes in row data from a dataframe and returns the category of that location obtained from foursquare. The second called get_foursquare does the actual information retrieval. It takes in a LGA as string and a query string then returns a data frame containing the names, categories, latitudes, longitudes and LGAs of the different retrieved Locations. The function get_category_type gets called in the function get_foursquare.

With these helper functions, I created a compound data frame of all results. A section of this is shown below.

Screenshot (454).png

I went through the unique categories and in doing so found some restaurants, classrooms and None values records. Rows with these were not added in a new data frame. This data frame was grouped by the categories and the frequency of each category was obtained. This is visualized in the choropleth and bar chart below.

Screenshot (444).png

Screenshot (443).png

I then went on to obtain clusters of the different local government areas. The aim of the clustering of LGAs is to suggest groups of neighborhoods that a restaurant interested in delivery can focus on as a start-up. The elbow method was then used to pick the optimum number of clusters as 6. The Kmeans clustering algorithm was then used to cluster the LGAs.

Screenshot (446).png

RESULTS

From the analysis of the number of offices in the different LGAs, the following LGAs were the top 5:

  • Eti-Osa
  • Ikeja
  • Mushin
  • Agege
  • Ikorodu

As a result of clustering the Local Government Areas, the following images show the top 2 clusters when the number of office and organisations are considered.

Screenshot (455).png

Screenshot (456).png

By observing a folium Map showing the different clusters, it was seen that clusters 0 and 1 with red and purple pointers were predominant.

Screenshot (457).png

DISCUSSION

With Lagos being the financial capital of Nigeria and having the highest population density in the country, it is no surprise that a lot of restaurants are interested in having branches here.

From the results obtained, I recommend the Local Government Areas: Eti-Osa, Ikeja, Mushin, Agege and Ikorodu as locations in Lagos Nigeria where a restaurant can situate their business.

For Entrepreneurs interested in food delivery to limited range of locations, I recommend starting with the neighborhoods: Amuwo Odofin, Apapa,Kosofe, Mushin, Oshodi/Isolo Ojo, Shomolu and Surulere OR Agege, Ajeromi/Ifelodun, Alimosho, Ifako/Ijaye, Ikeja and Ikorodu.

Keeping in mind that I limited this analysis to 11 search queries, its usefulness can be improved with a wider range of queries. This path can also be taken for Entrepreneurs and Organizations with other interests with some modifications. This analysis can also be tweaked to take into consideration the level of competition in the different areas.

CONCLUSION

Restaurant owners with the results of this analysis for their more specific situations can situate their businesses in areas where they are most likely to get customers.

A similar application in different sectors could facilitate the growth of the economy and the country as a whole

I hope this was an insightful read,

Fortune Adekogbe.