mlpack  2.0.1
naive_kmeans.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
17 #define __MLPACK_METHODS_KMEANS_NAIVE_KMEANS_HPP
18 
19 namespace mlpack {
20 namespace kmeans {
21 
31 template<typename MetricType, typename MatType>
33 {
34  public:
41  NaiveKMeans(const MatType& dataset, MetricType& metric);
42 
50  double Iterate(const arma::mat& centroids,
51  arma::mat& newCentroids,
52  arma::Col<size_t>& counts);
53 
54  size_t DistanceCalculations() const { return distanceCalculations; }
55 
56  private:
58  const MatType& dataset;
60  MetricType& metric;
61 
64 };
65 
66 } // namespace kmeans
67 } // namespace mlpack
68 
69 // Include implementation.
70 #include "naive_kmeans_impl.hpp"
71 
72 #endif
size_t DistanceCalculations() const
Linear algebra utility functions, generally performed on matrices or vectors.
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. ...