Tuesday, January 28, 2020

Brunswick Vs NZ Cities: The Sushi Challenge.

This post constitutes my final report for the IBM Applied Data Science Capstone course, as part of the IBM Data Science Professional Certificate.


The goal of this report was to demonstrate my ability to clearly define a problem that could be solved using location data, and then make calls to API's and use the data to solve the problem.

The code used to develop this report is available on my Github.


Introduction


I moved from Auckland, New Zealand to Brunswick, Melbourne, Australia, 6 years ago.

Both my parents (who live in Hamilton, NZ) and my parents-in-law (who live in Christchurch, NZ), are constantly asking me when I will move back home with my family.

There are many considerations about where to move to if I do head back to NZ, but since my favourite food is sushi, which of the 4 largest New Zealand cities should I live in, if I want to live in the center city and maximize my options for eating sushi within a walk-able 1.5 km zone?

Additionally, where would be the optimum location to find a house or apartment so that I was living in the center of these sushi venues?




I am only comparing the 4 largest cities in New Zealand to the City of Moreland (which encompasses Brunswick), as Moreland's population size in 2016 of 162,558 would make it the fourth largest city in New Zealand at that time.

The population of each of the four largest New Zealand cities in 2016 were as follows:


  • Auckland: 1 614 300   
  • Christchurch: 375 000   
  • Wellington: 207 900   
  • Hamilton: 161 200   
Obviously the audience for this analysis is focused on my own needs, but is also valuable to anyone else who loves sushi and will be visiting these five cities and staying centrally.


Data


I will use the Foursquare API's "venue", "category ID" and location data to compare the availability of sushi restaurants in my local city of Brunswick, located in Moreland to the four largest cities in New Zealand: Auckland, Wellington, Christchurch and Hamilton.

The data on population size was gathered from the Australian Bureau of Statistics' 2016 Census Data and Statistics New Zealand's 2016 Subnational Population  Estimates .

The restaurant data will be gathered only from venues within a radius of 1.5 km from the each cities' center coordinates, as defined by Foursquare.


Methodology


I used Google Colab to create the notebook for this project. All code was written in Python 3.0.

To find all of the sushi restaurants in each city within a 1.5 km radius of the city centers, requests were sent to the Foursquare API using the following the format:

url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&near={}&limit={}&radius={}&categoryId={}'.format(CLIENT_ID,CLIENT_SECRET,VERSION,city,LIMIT,radius,"4bf58dd8d48988d1d2941735")

Where the category ID was "4bf58dd8d48988d1d2941735" codes for 'sushi' in Foursquare.

The results were put into a data frame containing each cities' sushi venues' name, latitude and longitude, example below:



To determine which city had the most sushi restaurants within the defined 1.5 km radius, the total result for each query was tallied.

The python folium library was then used to visualize the location of each sushi venue in each city.

To determine the location that would be best suited to find a house or apartment in each city that would be the most central to all of the sushi venues, the mean latitude and longitude of the sushi venues was determined and then added to the map of each city, with lines leading to each venue.


Results


The number of sushi venues in each city, within a 1.5 km radius of the city center, were as follows:



  • Brunswick (54)
  • Auckland (46)
  • Wellington (35)
  • Hamilton (18)
  • Christchurch (8)


The locations that would be most beneficial to find a house or apartment, in order to minimize the average distance to each sushi venue, were as follows:



  • Brunswick [-37.789369092799696, 144.96825665600176]
  • Auckland [-36.85871458790793, 174.76689561211802]
  • Wellington [-41.287690684226455, 174.77693456845236]
  • Christchurch [-43.535147979870764, 172.63369264456878]
  • Hamilton [-43.535147979870764, 172.63369264456878]


These optimum living locations, with lines to each individual sushi venue, are visualised in the below maps:


Sushi venues within 1.5 km of Brunswick marked in blue, with the optimum living coordinates marked in a green circle.


Sushi venues within 1.5 km of Auckland city centre marked in blue, with the optimum living coordinates marked in a green circle.


Sushi venues within 1.5 km of Wellington City centre marked in blue, with the optimum living coordinates marked in a green circle.
Sushi venues within 1.5 km of Christchurch city centre marked in blue, with the optimum living coordinates marked in a green circle.
Sushi venues within 1.5 km of Hamilton city centre marked in blue, with the optimum living coordinates marked in a green circle.

Discussion


It makes sense that there are more sushi venues available close to my current location of Brunswick than for any of the New Zealand city centres, as the wider Melbourne population is far higher than any of the New Zealand cities examined here.

For future analysis I would enhance the transparency of the requests by including the location of the "City Centre" as defined by Foursquare on the map, to ascertain that it matches with the city centre as defined by local planning.

Given the population size of Christchurch I would have expected it to contain more sushi venues. As it is the only city located within the South Island of New Zealand, perhaps the cultural demographics differ compared to those in the North Island, which could be looked into in future studies.



Conclusion


In conclusion, it seems that if I were to choose a New Zealand city to move to, based solely on the number of sushi restaurants close to the city center, I would be moving back to my old home town of Auckland. Based on the mean location of sushi restaurants, I would ideally looking for a place to live in Grafton.

If I was looking to move closer to family as a secondary consideration, my parents will be happier than my partners', as Hamilton has more centrally located sushi restaurants than Christchurch.

Finally, I now know that I currently live 2.4 km north of my ideal sushi-based living zone, so if I'm looking to move in Melbourne I know where to focus my house search.

Tuesday, October 15, 2019

Adventures in Data Science: Progress

While brushing up on the algebra skills required for this Machine Learning course, I finished  "Logic and Computational Thinking" from Microsoft on EdEx.
I really enjoyed this course and so chose to go a little deeper with the IBM Data Science Professional Certificate, on Coursera.




The certificate consists of 9 courses, (I'm currently on #8) and so far I've learnt a lot about programming in python, data science methodology, SQL, databases, regression analysis, model evaluation and machine learning algorithms. The 7th course was "Data Visualisation with Python" and among other things I was able to turn raw data on 2016 crime rates in San Francisco into the Chloropleth Map below; so satisfying!
You can see the code for the data analysis and map creation on my Github here.
Raw crime data

Chloropleth map showing crime rates in San Francisco in 2016




Learning about data science and programming online has been the perfect mental stimulant for me while I negotiate the joyous yet tiring demands of being a new parent. The way the courses operate, I'm able to watch lectures and complete labs during naps, and complete longer assignments on the weekend. Having a tangible sense of progress and achievement in a new field has been really valuable to my sense of self, especially on the days when baby care seems all consuming.


Course certificate for Data Visualisation with Python






Once I finish this certificate, I think I'll focus on machine learning and a deep dive into python programming, so watch this space. If you're also getting into data science I would love to hear about what you're learning, the platforms you're using and what your goals are.

Friday, July 6, 2018

Back to basics.

As I suspected, I totally need to go back and brush up on my algebra skills in order to get the most out of the Machine Learning course.

Many data science sources online recommends Khan Academy as a wonderful (and free) way of learning the basics required for the course, so that's where I will start.

Wish me luck!

Thursday, July 5, 2018

Baby Steps: starting out in Data Science

Hello!

I am 38 weeks and 3 days pregnant today, and have been on maternity leave for two and a half blissful weeks. I've taken 12 months maternity leave from my role as a Territory Manager in technical sales, and want to undertake some self-guided learning during this time, so that I can continue to grow professionally, whilst undergoing the huge life change that is having my first child.

In May, I finished the course 'Foundations of Data Science: Computational Thinking With Python' through the University of Berkeley on EdEx and loved the challenge of it, so I've decided to continue focusing my learning in the field of data science.

With this intention, yesterday I signed up to 'Machine Learning' by Stanford University, on Coursera. This is an 11 week course, but it's kept open for 6 months, so even if the timing doesn't work out around a newborn, I can switch into another stream.

I should note at this stage that the Data Science course I did in May was the first time I'd really touched any maths since I finished University 5 years ago, so I may well need to take some more math classes to get where I need to be with this Machine Learning course.

I thought I'd start a blog as a record of my learning process, both to keep myself motivated and so that I'd have something to look back on; to track the highs and lows of my progress.

Thus begins Math, Machines and Milk- wish me luck!