Implementing the clustering algorithm
Our implementation has several pieces. The main piece is the implementation of the
-means clustering algorithm. The second piece is the logic to increase (or decrease) the number of clusters until the fit is satisfying. The third piece is to transform the latitude-longitude coordinates into three-dimensional space so that the clustering can be done. This is the first piece that we shall tackle since it is quite straightforward. The logic for setting the number of groups is certainly the hardest part, but we can’t test this until we have the
-means algorithm working.
Before we get started, we need to make some changes to our CMakeLists.txt and add new files to the clustering folder of our project. First, we create clustering/CMakeLists.txt, which will define the library target and the tests for this component of the project. This CMakeLists.txt should contain the following code:
add_library(ducky_clustering
clustering.h
clustering...