All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
k_means_clustering_engine_start_from_clusters_example.cpp
Go to the documentation of this file.
1 
8 
10 #include <vector>
11 #include <limits>
12 #include <cmath>
13 
15 #include "paal/utils/functors.hpp"
16 
17 int main() {
18 
19  // sample data
20  using Point = std::vector<int>;
21  std::vector<Point> points {{ 0, 0 }, { 0, 3 } , { 4, 0 }};
22  std::vector<std::vector<Point>> clusters = {
23  { { 0, 0 }, { 0, 3 } }, { { 4, 0 } }
24  };
25  std::vector<Point> centers(clusters.size());
26  std::vector<std::pair<Point, int>> point_cluster_pair;
27 
28  paal::centroids_minimalize_w_c_s_s(clusters, centers.begin());
29 
30  // solution
31  paal::k_means(points, centers, std::back_inserter(point_cluster_pair));
33 }
int main()
[K Means Clustering Engine Example]
auto k_means(Points &&points, Centers &&centers, OutputIterator result, Visitor visitor=Visitor{})
this is solve k_means_clustering problem and return vector of cluster example:
void centroids_minimalize_w_c_s_s(Clusters &&clusters, OutputIterator out)
centroid minimize within cluster sum of squares
This file contains set of simple useful functors or functor adapters.