mlpack  master
naive_kmeans.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
15 #define MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
16 
17 namespace mlpack {
18 namespace kmeans {
19 
29 template<typename MetricType, typename MatType>
31 {
32  public:
39  NaiveKMeans(const MatType& dataset, MetricType& metric);
40 
51  double Iterate(const arma::mat& centroids,
52  arma::mat& newCentroids,
53  arma::Col<size_t>& counts);
54 
55  size_t DistanceCalculations() const { return distanceCalculations; }
56 
57  private:
59  const MatType& dataset;
61  MetricType& metric;
62 
65 };
66 
67 } // namespace kmeans
68 } // namespace mlpack
69 
70 // Include implementation.
71 #include "naive_kmeans_impl.hpp"
72 
73 #endif
size_t DistanceCalculations() const
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
MetricType & metric
The instantiated metric.
const MatType & dataset
The dataset.
NaiveKMeans(const MatType &dataset, MetricType &metric)
Construct the NaiveKMeans object with the given dataset and metric.
double Iterate(const arma::mat &centroids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of the Lloyd algorithm, updating the given centroids into the newCentroids mat...
size_t distanceCalculations
Number of distance calculations.
This is an implementation of a single iteration of Lloyd&#39;s algorithm for k-means. ...