diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp index 9948b1057d..9e0c17a304 100644 --- a/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp +++ b/src/mlpack/methods/kmeans/dual_tree_kmeans.hpp @@ -67,7 +67,8 @@ class DualTreeKMeans const arma::Col& assignments, const arma::mat& oldCentroids, const arma::mat& dataset, - const std::vector& oldFromNew); + const std::vector& oldFromNew, + size_t& hamerlyPruned); }; template diff --git a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp index 22dd0ad376..083dcdd9e4 100644 --- a/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp +++ b/src/mlpack/methods/kmeans/dual_tree_kmeans_impl.hpp @@ -126,8 +126,9 @@ double DualTreeKMeans::Iterate( } // Update the tree with the centroid movement information. + size_t hamerlyPruned = 0; TreeUpdate(tree, centroids.n_cols, clusterDistances, assignments, - oldCentroids, dataset, oldFromNewCentroids); + oldCentroids, dataset, oldFromNewCentroids, hamerlyPruned); delete centroidTree; @@ -178,7 +179,8 @@ void DualTreeKMeans::TreeUpdate( const arma::Col& assignments, const arma::mat& centroids, const arma::mat& dataset, - const std::vector& oldFromNew) + const std::vector& oldFromNew, + size_t& hamerlyPruned) { // This is basically IterationUpdate(), but pulled out to be separate from the // actual dual-tree algorithm. @@ -453,8 +455,11 @@ node->Stat().SecondClosestBound() << " is too loose! -- " << secondClosestDist node->Stat().HamerlyPruned() = true; // if (node->Begin() == 16954) if (!node->Parent()->Stat().HamerlyPruned()) - Log::Warn << "Mark r" << node->Begin() << "c" << node->Count() << " as " - << "Hamerly pruned.\n"; + { +// Log::Warn << "Mark r" << node->Begin() << "c" << node->Count() << " as " +// << "Hamerly pruned.\n"; + hamerlyPruned += node->NumDescendants(); + } } // else // { @@ -499,13 +504,16 @@ node->Stat().SecondClosestBound() << " is too loose! -- " << secondClosestDist // if (!node->Stat().HamerlyPruned()) for (size_t i = 0; i < node->NumChildren(); ++i) TreeUpdate(&node->Child(i), clusters, clusterDistances, assignments, - centroids, dataset, oldFromNew); + centroids, dataset, oldFromNew, hamerlyPruned); node->Stat().LastSecondClosestBound() = node->Stat().SecondClosestBound() - clusterDistances[clusters]; // This should change later, but I'm not yet sure how to do it. node->Stat().SecondClosestBound() = DBL_MAX; node->Stat().SecondClosestQueryNode() = NULL; + + if (node->Parent() == NULL) + Log::Info << "Total Hamerly pruned points: " << hamerlyPruned << ".\n"; } } // namespace kmeans