max_variance_new_cluster.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_METHODS_KMEANS_MAX_VARIANCE_NEW_CLUSTER_HPP
15 #define MLPACK_METHODS_KMEANS_MAX_VARIANCE_NEW_CLUSTER_HPP
16 
17 #include <mlpack/prereqs.hpp>
18 
19 namespace mlpack {
20 namespace kmeans {
21 
27 {
28  public:
30  MaxVarianceNewCluster() : iteration(size_t(-1)) { }
31 
48  template<typename MetricType, typename MatType>
49  void EmptyCluster(const MatType& data,
50  const size_t emptyCluster,
51  const arma::mat& oldCentroids,
52  arma::mat& newCentroids,
53  arma::Col<size_t>& clusterCounts,
54  MetricType& metric,
55  const size_t iteration);
56 
58  template<typename Archive>
59  void serialize(Archive& ar, const unsigned int version);
60 
61  private:
63  size_t iteration;
65  arma::vec variances;
67  arma::Row<size_t> assignments;
68 
70  template<typename MetricType, typename MatType>
71  void Precalculate(const MatType& data,
72  const arma::mat& oldCentroids,
73  arma::Col<size_t>& clusterCounts,
74  MetricType& metric);
75 };
76 
77 } // namespace kmeans
78 } // namespace mlpack
79 
80 // Include implementation.
81 #include "max_variance_new_cluster_impl.hpp"
82 
83 #endif
void serialize(Archive &ar, const unsigned int version)
Serialize the object.
.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
void EmptyCluster(const MatType &data, const size_t emptyCluster, const arma::mat &oldCentroids, arma::mat &newCentroids, arma::Col< size_t > &clusterCounts, MetricType &metric, const size_t iteration)
Take the point furthest from the centroid of the cluster with maximum variance to be a new cluster...
MaxVarianceNewCluster()
Default constructor required by EmptyClusterPolicy.
When an empty cluster is detected, this class takes the point furthest from the centroid of the clust...