1#ifndef KMEANS_KMEANS_HPP
2#define KMEANS_KMEANS_HPP
6#include "sanisizer/sanisizer.hpp"
57template<
typename Index_,
typename Data_,
typename Cluster_,
typename Float_,
class Matrix_ = Matrix<Index_, Data_> >
66 auto actual_centers = initialize.
run(data, num_centers, centers);
67 auto output = refine.
run(data, actual_centers, centers, clusters);
68 sanisizer::resize(output.sizes, num_centers);
92template<
typename Index_,
typename Data_,
typename Cluster_,
typename Float_>
97 const Cluster_ num_centers,
98 Float_*
const centers,
99 Cluster_*
const clusters)
101 return compute<Index_, Data_, Cluster_, Float_, Matrix<Index_, Data_> >(data, initialize, refine, num_centers, centers, clusters);
107template<
typename Index_,
typename Cluster_,
typename Float_>
112 Results(
const std::size_t num_dimensions,
const Index_ num_observations,
const Cluster_ num_centers) :
113 centers(sanisizer::product<
decltype(I(
centers.size()))>(num_dimensions, num_centers)),
159template<
typename Index_,
typename Data_,
typename Cluster_,
typename Float_,
class Matrix_ = Matrix<Index_, Data_> >
164 const Cluster_ num_centers)
167 sanisizer::resize(output.
clusters, data.num_observations());
168 output.
centers.resize(sanisizer::product<
decltype(I(output.
centers.size()))>(num_centers, data.num_dimensions()));
189template<
typename Index_,
typename Data_,
typename Cluster_,
typename Float_>
194 const Cluster_ num_centers)
Report detailed clustering statistics.
Class for kmeans++ initialization.
Class for no initialization.
Class for random initialization.
k-means initialization with variance partitioning.
Interface for k-means initialization.
Interface for matrix inputs.
Implements the Hartigan-Wong algorithm for k-means clustering.
Implements the Lloyd algorithm for k-means clustering.
Implements the mini-batch algorithm for k-means clustering.
Interface for k-means refinement.
Wrapper for a simple dense matrix.
Interface for k-means initialization algorithms.
Definition Initialize.hpp:29
virtual Cluster_ run(const Matrix_ &data, Cluster_ num_centers, Float_ *centers) const =0
Interface for matrix data.
Definition Matrix.hpp:133
Interface for k-means refinement algorithms.
Definition Refine.hpp:30
virtual Details< Index_ > run(const Matrix_ &data, Cluster_ num_centers, Float_ *centers, Cluster_ *clusters) const =0
Compute within-cluster sum of squares.
Perform k-means clustering.
Definition compute_wcss.hpp:16
Details< Index_ > compute(const Matrix_ &data, const Initialize< Index_, Data_, Cluster_, Float_, Matrix_ > &initialize, const Refine< Index_, Data_, Cluster_, Float_, Matrix_ > &refine, Cluster_ num_centers, Float_ *centers, Cluster_ *clusters)
Definition kmeans.hpp:58
Additional statistics from the k-means algorithm.
Definition Details.hpp:20
Results of the k-means clustering.
Definition kmeans.hpp:108
std::vector< Float_ > centers
Definition kmeans.hpp:133
Details< Index_ > details
Definition kmeans.hpp:138
std::vector< Cluster_ > clusters
Definition kmeans.hpp:126