All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
Namespaces | Functions
k_means_clustering.hpp File Reference
#include "paal/clustering/k_means_clustering_engine.hpp"
#include "paal/utils/irange.hpp"
#include <boost/range/algorithm_ext/iota.hpp>
#include <boost/range/empty.hpp>
#include <vector>

Go to the source code of this file.

Namespaces

 paal
 global namespace of project.
 

Functions

template<typename Cluster , typename OutputIterator >
void paal::centroid_minimalize_w_c_s_s (Cluster &&cluster, OutputIterator out)
 return centroid that minimize within-cluster sum of squares
 
template<typename Clusters , typename OutputIterator >
void paal::centroids_minimalize_w_c_s_s (Clusters &&clusters, OutputIterator out)
 centroid minimize within cluster sum of squares More...
 
template<typename Points , class Centers , class OutputIterator , class Visitor = k_means_visitor>
auto paal::k_means (Points &&points, Centers &&centers, OutputIterator result, Visitor visitor=Visitor{})
 this is solve k_means_clustering problem and return vector of cluster example:

#include <vector>
#include <iostream>
int main() {
using Point = std::vector<double>;
// sample data
unsigned const int NUMBER_OF_CLUSTER = 2;
std::vector<Point> points = { { 0, 0 },
{ 0, 3 },
{ 4, 0 } };
std::vector<std::pair<Point , int>> point_cluster_pair;
std::vector<Point> centers(NUMBER_OF_CLUSTER);
// solution
paal::get_random_centers(points, NUMBER_OF_CLUSTER, centers.begin());
paal::k_means(points , centers,
back_inserter(point_cluster_pair));
for (auto i : point_cluster_pair) {
for(auto && j : i.first) {
std::cout << j << ",";
}
std::cout<< " " << i.second << std::endl;
}
More...
 

Detailed Description

Author
Piotr Smulewicz, Piotr Wygocki
Version
1.0
Date
2014-06-25

Definition in file k_means_clustering.hpp.