mlpack
Classes | Typedefs | Functions
mlpack::kmeans Namespace Reference

K-Means clustering. More...

Classes

class  AllowEmptyClusters
 Policy which allows K-Means to create empty clusters without any error being reported. More...
 
class  DualTreeKMeans
 An algorithm for an exact Lloyd iteration which simply uses dual-tree nearest-neighbor search to find the nearest centroid for each point in the dataset. More...
 
class  DualTreeKMeansRules
 
class  DualTreeKMeansStatistic
 
class  ElkanKMeans
 
struct  GivesCentroids
 'value' is true if the InitialPartitionPolicy class has a member Cluster(const arma::mat& data, const size_t clusters, arma::mat& centroids). More...
 
class  HamerlyKMeans
 
class  KillEmptyClusters
 Policy which allows K-Means to "kill" empty clusters without any error being reported. More...
 
class  KMeans
 This class implements K-Means clustering, using a variety of possible implementations of Lloyd's algorithm. More...
 
class  MaxVarianceNewCluster
 When an empty cluster is detected, this class takes the point furthest from the centroid of the cluster with maximum variance as a new cluster. More...
 
class  NaiveKMeans
 This is an implementation of a single iteration of Lloyd's algorithm for k-means. More...
 
class  PellegMooreKMeans
 An implementation of Pelleg-Moore's 'blacklist' algorithm for k-means clustering. More...
 
class  PellegMooreKMeansRules
 The rules class for the single-tree Pelleg-Moore kd-tree traversal for k-means clustering. More...
 
class  PellegMooreKMeansStatistic
 A statistic for trees which holds the blacklist for Pelleg-Moore k-means clustering (which represents the clusters that cannot possibly own any points in a node). More...
 
class  RandomPartition
 A very simple partitioner which partitions the data randomly into the number of desired clusters. More...
 
class  RefinedStart
 A refined approach for choosing initial points for k-means clustering. More...
 
class  SampleInitialization
 

Typedefs

template<typename MetricType , typename MatType >
using DefaultDualTreeKMeans = DualTreeKMeans< MetricType, MatType >
 A template typedef for the DualTreeKMeans algorithm with the default tree type (a kd-tree). More...
 
template<typename MetricType , typename MatType >
using CoverTreeDualTreeKMeans = DualTreeKMeans< MetricType, MatType, tree::StandardCoverTree >
 A template typedef for the DualTreeKMeans algorithm with the cover tree type. More...
 

Functions

template<typename TreeType >
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. More...
 
template<typename TreeType >
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. More...
 
template<typename TreeType >
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.
 
template<typename TreeType >
void RestoreChildren (TreeType &node, const typename std::enable_if_t< tree::TreeTraits< TreeType >::BinaryTree > *junk=0)
 Utility function for restoring children to a binary tree. More...
 
template<typename TreeType , typename MatType >
TreeType * BuildTree (MatType &&dataset, std::vector< size_t > &oldFromNew, const typename std::enable_if< tree::TreeTraits< TreeType >::RearrangesDataset >::type *=0)
 Call the tree constructor that does mapping.
 
template<typename TreeType , typename MatType >
TreeType * BuildTree (MatType &&dataset, const std::vector< size_t > &, const typename std::enable_if< !tree::TreeTraits< TreeType >::RearrangesDataset >::type *=0)
 Call the tree constructor that does not do mapping.
 
template<typename TreeType >
void RestoreChildren (TreeType &node, const typename std::enable_if_t< !tree::TreeTraits< TreeType >::BinaryTree > *)
 Utility function for restoring children in a non-binary tree.
 
 HAS_MEM_FUNC (Cluster, GivesCentroidsCheck)
 This gives us a GivesCentroids object that we can use to tell whether or not an InitialPartitionPolicy returns centroids or point assignments.
 
template<typename MatType , typename InitialPartitionPolicy >
bool GetInitialAssignmentsOrCentroids (InitialPartitionPolicy &ipp, const MatType &data, const size_t clusters, arma::Row< size_t > &assignments, arma::mat &, const typename std::enable_if_t< !GivesCentroids< InitialPartitionPolicy >::value > *=0)
 Call the initial partition policy, if it returns assignments. More...
 
template<typename MatType , typename InitialPartitionPolicy >
bool GetInitialAssignmentsOrCentroids (InitialPartitionPolicy &ipp, const MatType &data, const size_t clusters, arma::Row< size_t > &, arma::mat &centroids, const typename std::enable_if_t< GivesCentroids< InitialPartitionPolicy >::value > *=0)
 Call the initial partition policy, if it returns centroids. More...
 

Detailed Description

K-Means clustering.

Typedef Documentation

◆ CoverTreeDualTreeKMeans

template<typename MetricType , typename MatType >
using mlpack::kmeans::CoverTreeDualTreeKMeans = typedef DualTreeKMeans<MetricType, MatType, tree::StandardCoverTree>

A template typedef for the DualTreeKMeans algorithm with the cover tree type.

◆ DefaultDualTreeKMeans

template<typename MetricType , typename MatType >
using mlpack::kmeans::DefaultDualTreeKMeans = typedef DualTreeKMeans<MetricType, MatType>

A template typedef for the DualTreeKMeans algorithm with the default tree type (a kd-tree).

Function Documentation

◆ GetInitialAssignmentsOrCentroids() [1/2]

template<typename MatType , typename InitialPartitionPolicy >
bool mlpack::kmeans::GetInitialAssignmentsOrCentroids ( InitialPartitionPolicy &  ipp,
const MatType &  data,
const size_t  clusters,
arma::Row< size_t > &  assignments,
arma::mat &  ,
const typename std::enable_if_t< !GivesCentroids< InitialPartitionPolicy >::value > *  = 0 
)

Call the initial partition policy, if it returns assignments.

This returns 'true' to indicate that assignments were given.

◆ GetInitialAssignmentsOrCentroids() [2/2]

template<typename MatType , typename InitialPartitionPolicy >
bool mlpack::kmeans::GetInitialAssignmentsOrCentroids ( InitialPartitionPolicy &  ipp,
const MatType &  data,
const size_t  clusters,
arma::Row< size_t > &  ,
arma::mat &  centroids,
const typename std::enable_if_t< GivesCentroids< InitialPartitionPolicy >::value > *  = 0 
)

Call the initial partition policy, if it returns centroids.

This returns 'false' to indicate that assignments were not given.

◆ HideChild() [1/2]

template<typename TreeType >
void mlpack::kmeans::HideChild ( TreeType &  node,
const size_t  child,
const typename std::enable_if_t< !tree::TreeTraits< TreeType >::BinaryTree > *  junk = 0 
)

Utility function for hiding children.

Utility function for hiding children in a non-binary tree.

This actually does something, and is called if the tree is not a binary tree.

◆ HideChild() [2/2]

template<typename TreeType >
void mlpack::kmeans::HideChild ( TreeType &  node,
const size_t  child,
const typename std::enable_if_t< tree::TreeTraits< TreeType >::BinaryTree > *  junk = 0 
)

Utility function for hiding children.

Utility function for hiding children in a binary tree.

This is called when the tree is a binary tree, and does nothing, because we don't hide binary children in this way.

◆ RestoreChildren()

template<typename TreeType >
void mlpack::kmeans::RestoreChildren ( TreeType &  node,
const typename std::enable_if_t< tree::TreeTraits< TreeType >::BinaryTree > *  junk = 0 
)

Utility function for restoring children to a binary tree.

Utility function for restoring children in a binary tree.