The rules class for the single-tree Pelleg-Moore kd-tree traversal for k-means clustering. More...
Public Member Functions | |
PellegMooreKMeansRules (const typename TreeType::Mat &dataset, const arma::mat ¢roids, arma::mat &newCentroids, arma::Col< size_t > &counts, MetricType &metric) | |
Create the PellegMooreKMeansRules object. More... | |
double | BaseCase (const size_t queryIndex, const size_t referenceIndex) |
The BaseCase() function for this single-tree algorithm does nothing. More... | |
size_t | DistanceCalculations () const |
Get the number of distance calculations that have been performed. More... | |
size_t & | DistanceCalculations () |
Modify the number of distance calculations that have been performed. More... | |
double | Rescore (const size_t queryIndex, TreeType &referenceNode, const double oldScore) |
Rescore to determine if a node can be pruned. More... | |
double | Score (const size_t queryIndex, TreeType &referenceNode) |
Determine if a cluster can be pruned, and if not, perform point-to-cluster comparisons. More... | |
The rules class for the single-tree Pelleg-Moore kd-tree traversal for k-means clustering.
Although TreeType is a free template parameter, this particular implementation is specialized to trees with hyper-rectangle bounds due to the pruning rule used to determine if one cluster dominates a node with respect to another cluster.
Our implementation here abuses the single-tree algorithm abstractions a little bit. Instead of doing a traversal for a particular query point, in this case we consider all clusters at once—so the query point is entirely ignored during in BaseCase() and Score().
Definition at line 33 of file pelleg_moore_kmeans_rules.hpp.
PellegMooreKMeansRules | ( | const typename TreeType::Mat & | dataset, |
const arma::mat & | centroids, | ||
arma::mat & | newCentroids, | ||
arma::Col< size_t > & | counts, | ||
MetricType & | metric | ||
) |
Create the PellegMooreKMeansRules object.
dataset | The dataset that the tree is built on. |
centroids | The current centroids. |
newCentroids | New centroids after this iteration (output). |
counts | Current cluster counts, to be replaced with new cluster counts. |
metric | Instantiated metric. |
double BaseCase | ( | const size_t | queryIndex, |
const size_t | referenceIndex | ||
) |
The BaseCase() function for this single-tree algorithm does nothing.
Instead, point-to-cluster comparisons are handled as necessary in Score().
queryIndex | Index of query point (fake, will be ignored). |
referenceIndex | Index of reference point. |
|
inline |
Get the number of distance calculations that have been performed.
Definition at line 84 of file pelleg_moore_kmeans_rules.hpp.
|
inline |
Modify the number of distance calculations that have been performed.
Definition at line 86 of file pelleg_moore_kmeans_rules.hpp.
double Rescore | ( | const size_t | queryIndex, |
TreeType & | referenceNode, | ||
const double | oldScore | ||
) |
Rescore to determine if a node can be pruned.
In this case, a node can never be pruned during rescoring, so this just returns oldScore.
queryIndex | Index of query point (fake, will be ignored). |
referenceNode | Node containing points in the dataset. |
oldScore | Resulting score from Score(). |
double Score | ( | const size_t | queryIndex, |
TreeType & | referenceNode | ||
) |
Determine if a cluster can be pruned, and if not, perform point-to-cluster comparisons.
The point-to-cluster comparisons are performed here and not in BaseCase() because of the complexity of managing the blacklist.
queryIndex | Index of query point (fake, will be ignored). |
referenceNode | Node containing points in the dataset. |