17 #ifndef __MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_HPP 18 #define __MLPACK_METHODS_KMEANS_DUAL_TREE_KMEANS_HPP 39 template<
typename TreeMetricType,
40 typename TreeStatType,
47 typedef TreeType<MetricType, DualTreeKMeansStatistic, MatType>
Tree;
49 template<
typename TreeMetricType,
50 typename IgnoredStatType,
53 TreeType<TreeMetricType, DualTreeKMeansStatistic, TreeMatType>;
74 double Iterate(
const arma::mat& centroids,
75 arma::mat& newCentroids,
76 arma::Col<size_t>& counts);
118 const arma::mat& centroids,
119 const double parentUpperBound = 0.0,
120 const double adjustedParentUpperBound = DBL_MAX,
121 const double parentLowerBound = DBL_MAX,
122 const double adjustedParentLowerBound = 0.0);
126 arma::mat& newCentroids,
127 arma::Col<size_t>& newCounts,
128 arma::mat& centroids);
136 template<
typename TreeType>
139 const typename boost::disable_if_c<
145 template<
typename TreeType>
148 const typename boost::enable_if_c<
152 template<
typename TreeType>
155 TreeType>::BinaryTree>::type* junk = 0);
158 template<
typename TreeType>
161 TreeType>::BinaryTree>::type* junk = 0);
165 template<
typename MetricType,
typename MatType>
170 template<
typename MetricType,
typename MatType>
177 #include "dual_tree_kmeans_impl.hpp" BinarySpaceTree< MetricType, StatisticType, MatType, bound::HRectBound, MidpointSplit > KDTree
The standard midpoint-split kd-tree.
void HideChild(TreeType &node, const size_t child, const typename boost::disable_if_c< tree::TreeTraits< TreeType >::BinaryTree >::type *junk=0)
Utility function for hiding children.
TreeType< MetricType, DualTreeKMeansStatistic, MatType > Tree
Convenience typedef.
Linear algebra utility functions, generally performed on matrices or vectors.
arma::vec upperBounds
Upper bounds on nearest centroid.
~DualTreeKMeans()
Delete the tree constructed by the DualTreeKMeans object.
size_t distanceCalculations
Track distance calculations.
MetricType metric
The metric.
An algorithm for an exact Lloyd iteration which simply uses dual-tree nearest-neighbor search to find...
void ExtractCentroids(Tree &node, arma::mat &newCentroids, arma::Col< size_t > &newCounts, arma::mat ¢roids)
Extract the centroids of the clusters.
void RestoreChildren(TreeType &node, const typename boost::disable_if_c< tree::TreeTraits< TreeType >::BinaryTree >::type *junk=0)
Utility function for restoring children to a non-binary tree.
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
size_t DistanceCalculations() const
Return the number of distance calculations.
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()
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...