mlpack  master
kill_empty_clusters.hpp
Go to the documentation of this file.
1 
13 #ifndef __MLPACK_METHODS_KMEANS_KILL_EMPTY_CLUSTERS_HPP
14 #define __MLPACK_METHODS_KMEANS_KILL_EMPTY_CLUSTERS_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace kmeans {
20 
26 {
27  public:
30 
48  template<typename MetricType, typename MatType>
49  static inline force_inline size_t EmptyCluster(
50  const MatType& /* data */,
51  const size_t emptyCluster,
52  const arma::mat& /* oldCentroids */,
53  arma::mat& newCentroids,
54  arma::Col<size_t>& /* clusterCounts */,
55  MetricType& /* metric */,
56  const size_t /* iteration */)
57  {
58  // Kill the empty cluster.
59  newCentroids.col(emptyCluster).fill(DBL_MAX);
60  return 0; // No points were changed.
61  }
62 
64  template<typename Archive>
65  void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
66 };
67 
68 } // namespace kmeans
69 } // namespace mlpack
70 
71 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Serialize(Archive &, const unsigned int)
Serialize the empty cluster policy (nothing to do).
static force_inline size_t EmptyCluster(const MatType &, const size_t emptyCluster, const arma::mat &, arma::mat &newCentroids, arma::Col< size_t > &, MetricType &, const size_t)
This function sets an empty cluster found during k-means to all DBL_MAX (i.e.
#define force_inline
Definition: prereqs.hpp:44
Policy which allows K-Means to "kill" empty clusters without any error being reported.
KillEmptyClusters()
Default constructor required by EmptyClusterPolicy policy.