15 #ifndef MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_HPP 16 #define MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_HPP 37 template<
typename TreeMetricType,
38 typename TreeStatType,
45 typedef TreeType<MetricType, DualTreeKMeansStatistic, MatType>
Tree;
47 template<
typename TreeMetricType,
48 typename IgnoredStatType,
51 TreeType<TreeMetricType, DualTreeKMeansStatistic, TreeMatType>;
72 double Iterate(
const arma::mat& centroids,
73 arma::mat& newCentroids,
74 arma::Col<size_t>& counts);
116 const arma::mat& centroids,
117 const double parentUpperBound = 0.0,
118 const double adjustedParentUpperBound = DBL_MAX,
119 const double parentLowerBound = DBL_MAX,
120 const double adjustedParentLowerBound = 0.0);
124 arma::mat& newCentroids,
125 arma::Col<size_t>& newCounts,
126 const arma::mat& centroids);
134 template<
typename TreeType>
143 template<
typename TreeType>
150 template<
typename TreeType>
153 TreeType>::BinaryTree>* junk = 0);
156 template<
typename TreeType>
159 TreeType>::BinaryTree>* junk = 0);
163 template<
typename MetricType,
typename MatType>
168 template<
typename MetricType,
typename MatType>
175 #include "dual_tree_kmeans_impl.hpp" BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
TreeType< MetricType, DualTreeKMeansStatistic, MatType > Tree
Convenience typedef.
void HideChild(TreeType &node, const size_t child, const typename std::enable_if_t< !tree::TreeTraits< TreeType >::BinaryTree > *junk=0)
Utility function for hiding children.
Linear algebra utility functions, generally performed on matrices or vectors.
arma::vec upperBounds
Upper bounds on nearest centroid.
void ExtractCentroids(Tree &node, arma::mat &newCentroids, arma::Col< size_t > &newCounts, const arma::mat ¢roids)
Extract the centroids of the clusters.
~DualTreeKMeans()
Delete the tree constructed by the DualTreeKMeans object.
size_t distanceCalculations
Track distance calculations.
MetricType metric
The metric.
void RestoreChildren(TreeType &node, const typename std::enable_if_t<!tree::TreeTraits< TreeType >::BinaryTree > *junk=0)
Utility function for restoring children to a non-binary tree.
An algorithm for an exact Lloyd iteration which simply uses dual-tree nearest-neighbor search to find...
Tree * tree
The tree built on the points.
void UpdateTree(Tree &node, const arma::mat ¢roids, const double parentUpperBound=0.0, const double adjustedParentUpperBound=DBL_MAX, const double parentLowerBound=DBL_MAX, const double adjustedParentLowerBound=0.0)
Update the bounds in the tree before the next iteration.
arma::vec lowerBounds
Lower bounds on second closest cluster distance for each point.
const MatType & datasetOrig
The original dataset reference.
void CoalesceTree(Tree &node, const size_t child=0)
TreeType< TreeMetricType, DualTreeKMeansStatistic, TreeMatType > NNSTreeType
std::vector< bool > visited
double Iterate(const arma::mat ¢roids, arma::mat &newCentroids, arma::Col< size_t > &counts)
Run a single iteration of the dual-tree nearest neighbor algorithm for k-means, updating the given ce...
arma::mat lastIterationCentroids
arma::Row< size_t > assignments
void DecoalesceTree(Tree &node)
DualTreeKMeans(const MatType &dataset, MetricType &metric)
Construct the DualTreeKMeans object, which will construct a tree on the points.
const MatType & dataset
The dataset we are using.
std::vector< bool > prunedPoints
Indicator of whether or not the point is pruned.
The TreeTraits class provides compile-time information on the characteristics of a given tree type...
arma::vec clusterDistances
arma::mat interclusterDistances
size_t DistanceCalculations() const
Return the number of distance calculations.
size_t & DistanceCalculations()
Modify the number of distance calculations.
size_t iteration
Track iteration number.
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
typename enable_if< B, T >::type enable_if_t