mlpack  2.0.1
max_variance_new_cluster.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_METHODS_KMEANS_MAX_VARIANCE_NEW_CLUSTER_HPP
17 #define __MLPACK_METHODS_KMEANS_MAX_VARIANCE_NEW_CLUSTER_HPP
18 
19 #include <mlpack/core.hpp>
20 
21 namespace mlpack {
22 namespace kmeans {
23 
29 {
30  public:
32  MaxVarianceNewCluster() : iteration(size_t(-1)) { }
33 
50  template<typename MetricType, typename MatType>
51  size_t EmptyCluster(const MatType& data,
52  const size_t emptyCluster,
53  const arma::mat& oldCentroids,
54  arma::mat& newCentroids,
55  arma::Col<size_t>& clusterCounts,
56  MetricType& metric,
57  const size_t iteration);
58 
60  template<typename Archive>
61  void Serialize(Archive& ar, const unsigned int version);
62 
63  private:
65  size_t iteration;
67  arma::vec variances;
69  arma::Row<size_t> assignments;
70 
72  template<typename MetricType, typename MatType>
73  void Precalculate(const MatType& data,
74  const arma::mat& oldCentroids,
75  arma::Col<size_t>& clusterCounts,
76  MetricType& metric);
77 };
78 
79 } // namespace kmeans
80 } // namespace mlpack
81 
82 // Include implementation.
83 #include "max_variance_new_cluster_impl.hpp"
84 
85 #endif
size_t iteration
Index of iteration for which variance is cached.
Linear algebra utility functions, generally performed on matrices or vectors.
MaxVarianceNewCluster()
Default constructor required by EmptyClusterPolicy.
When an empty cluster is detected, this class takes the point furthest from the centroid of the clust...
void Serialize(Archive &ar, const unsigned int version)
Serialize the object.
size_t 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...
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
void Precalculate(const MatType &data, const arma::mat &oldCentroids, arma::Col< size_t > &clusterCounts, MetricType &metric)
Called when we are on a new iteration.
arma::Row< size_t > assignments
Cached assignments for each point.
arma::vec variances
Cached variances for each cluster.