template<size_t K, typename T, typename I = unsigned long>
struct KMeansVisitor;
|
This is a “single action visitor”, meaning it is passed the whole data vector in one call and you must use the single_action_visit() interface.
This functor class finds the K means in the data. It could also cluster the data round the means.
The constructor takes two parameters
- Number of iterations
- A function to calculate distance between to data points of type T with a default value
KMeansVisitor(size_type num_of_iter,
distance_func f = [](const value_type &x, const value_type &y) -> double {
return ((x - y) * (x - y));
})
The result type is an array of K means of type T.
There is also a get_clusters() method that returns an array of K VectorPtrView’s which contain the data clustered around the K-Means. The first element in each VectorPtrView is the mean and the reset are the data points belonging to that cluster.
|
K: Number of means to find
T: Column data type
I: Index type
|