Member-only story

K-means algorithm to visit a new city

Didier Rodrigues Lopes
3 min readAug 1, 2021

--

https://github.com/DidierRLopes/LondonVisit

Usually when I book a weekend getaway, I spend quite some time doing 2 things:

  • Writing down the main attractions I want to see
  • Depicting the travel path to maximise efficiency and see the most in less time (I’m a bit of an efficiency freak myself, sorry)

This repository aims to decide which attractions to visit in London as a function of the number of days that you will be visiting, by applying K-means algorithm.

As input you need to give the GPS coordinates of the main attractions you want to visit during your stay, and the number of days you are planning to visit. Notice that attractions that are not within the map screenshot boundaries will be discarded. See disclaimer below.

The K-means algorithm will interpret: List of GPS coordinates of the main attractions that you want to visit as 2D samples, after converting to UTM. Number of days of the visit as Number of clusters.

Of course, this is rather unrealistic because of several reasons, such as:

  • Not taking into account if they want to just pass by the London Eye, or have a ride on it;
  • Assumes that we are in a no man’s land since it completely bypasses the existence of other buildings, roads, …;
  • Does not consider altitude, even though London is rather plane;
  • Does not consider the number of…

--

--

No responses yet