libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Functions
Clustering

Namespaces

 crn::kmedoids
 k medoids
 

Classes

struct  crn::IterativeClustering< T, type >
 A utility class to create clusters iteratively. More...
 
class  crn::kMeans< T, type, type >
 k-means clustering algorithm More...
 
class  crn::IterativekNN< DataType, DistFunc >
 Iterative kNN. More...
 
class  crn::LazyDistanceMatrix< DATA, DISTANCE >
 Lazy computation of a distance matrix. More...
 
class  crn::SpectralClustering
 Spectral clustering. More...
 

Functions

template<typename ITER , typename std::enable_if< std::is_copy_assignable< typename std::iterator_traits< ITER >::value_type >::value &&std::is_assignable< typename std::add_lvalue_reference< typename std::decay< typename std::iterator_traits< ITER >::value_type >::type >::type, int >::value &&traits::HasLT< typename std::iterator_traits< ITER >::value_type >::value &&IsVectorOverR< typename std::iterator_traits< ITER >::value_type >::value, int >::type = 0>
std::pair< typename
std::iterator_traits< ITER >
::value_type, typename
std::iterator_traits< ITER >
::value_type > 
crn::TwoMeans (ITER beg, ITER en, double stop_crit=0.00001)
 2-means clustering algorithm for scalar data More...
 
template<typename ITER >
std::pair< typename
std::iterator_traits< ITER >
::value_type, typename
std::iterator_traits< ITER >
::value_type > 
crn::TwoMeans (ITER beg, ITER en, typename std::iterator_traits< ITER >::value_type p1, typename std::iterator_traits< ITER >::value_type p2, double stop_crit=0.00001) noexcept(std::is_nothrow_constructible< typename std::iterator_traits< ITER >::value_type >::value &&std::is_nothrow_copy_assignable< typename std::iterator_traits< ITER >::value_type >::value)
 2-means clustering algorithm for scalar data More...
 
template<typename DATA , typename DISTANCE >
LazyDistanceMatrix< DATA,
DISTANCE > 
crn::MakeLazyDistanceMatrix (const std::vector< DATA > &d, DISTANCE &&dist)
 Helper to avoid typing long type names. More...
 
std::vector< double > crn::ComputeLOF (const SquareMatrixDouble &distmat, size_t k)
 Compute the Local Outlier Factor for each element from the distance matrix. More...
 
std::vector< double > crn::ComputeLOF (const std::vector< std::vector< double >> &distmat, size_t k)
 Compute the Local Outlier Factor for each element from the distance matrix. More...
 
std::vector< double > crn::ComputeLoOP (const SquareMatrixDouble &distmat, size_t k, double lambda)
 compute the local outlier probability for each element from the distance matrix More...
 
std::vector< double > crn::ComputeLoOP (const std::vector< std::vector< double >> &distmat, size_t k, double lambda)
 compute the local outlier probability for each element from the distance matrix More...
 
enum  crn::AProClusters { crn::AProClusters::MEDIUM, crn::AProClusters::LOW }
 Strategies to limit the number of classes in affinity propagation. More...
 
std::pair< std::vector< size_t >
, std::vector< size_t > > 
crn::AffinityPropagation (const SquareMatrixDouble &distance_matrix, AProClusters nclusters, double damping=0.5, size_t stable_iters_stop=10, size_t max_iter=100)
 Computes clusters and their prototypes. More...
 
std::pair< std::vector< size_t >
, std::vector< size_t > > 
crn::AffinityPropagation (const SquareMatrixDouble &distance_matrix, double preference, double damping=0.5, size_t stable_iters_stop=10, size_t max_iter=100)
 Computes clusters and their prototypes. More...
 
std::pair< std::vector< size_t >
, std::vector< size_t > > 
crn::AffinityPropagation (const SquareMatrixDouble &distance_matrix, const std::vector< double > &preference, double damping=0.5, size_t stable_iters_stop=10, size_t max_iter=100)
 Computes clusters and their prototypes. More...
 

Detailed Description

Enumeration Type Documentation

enum crn::AProClusters
strong

Strategies to limit the number of classes in affinity propagation.

Enumerator
MEDIUM 
LOW 

Definition at line 36 of file CRNAffinityPropagation.h.

Function Documentation

std::pair< std::vector< size_t >, std::vector< size_t > > crn::AffinityPropagation ( const SquareMatrixDouble distance_matrix,
AProClusters  nclusters,
double  damping = 0.5,
size_t  stable_iters_stop = 10,
size_t  max_iter = 100 
)

Computes clusters and their prototypes.

Computes clusters and their prototypes

Parameters
[in]distance_matrixthe distance matrix of the elements to cluster
[in]nclustersthe strategy to limit the number of clusters
[in]dampingthe damping rate. 0 = no damping, default = 0.5. The higher the value the slower the algorithm will converge. Low values may result in oscillations.
[in]stable_iters_stopnumber of consecutive identical clusterings to stop the algorithm (default = 10).
[in]max_itermaximum number of iterations (default = 100).
Returns
a pair containing in first the indexes of the cluster prototypes and in second the cluster number for each element.

Definition at line 128 of file CRNAffinityPropagation.cpp.

std::pair< std::vector< size_t >, std::vector< size_t > > crn::AffinityPropagation ( const SquareMatrixDouble distance_matrix,
double  preference,
double  damping = 0.5,
size_t  stable_iters_stop = 10,
size_t  max_iter = 100 
)

Computes clusters and their prototypes.

Computes clusters and their prototypes

Parameters
[in]distance_matrixthe distance matrix of the elements to cluster
[in]preferencethe "preference" value that drives the number of cluster (e.g: mean, median or max distance). The higher the value, the smaller the number of clusters.
[in]dampingthe damping rate. 0 = no damping, default = 0.5. The higher the value the slower the algorithm will converge. Low values may result in oscillations.
[in]stable_iters_stopnumber of consecutive identical clusterings to stop the algorithm (default = 10).
[in]max_itermaximum number of iterations (default = 100).
Returns
a pair containing in first the indexes of the cluster prototypes and in second the cluster number for each element.

Definition at line 160 of file CRNAffinityPropagation.cpp.

std::pair< std::vector< size_t >, std::vector< size_t > > crn::AffinityPropagation ( const SquareMatrixDouble distance_matrix,
const std::vector< double > &  preference,
double  damping = 0.5,
size_t  stable_iters_stop = 10,
size_t  max_iter = 100 
)

Computes clusters and their prototypes.

Computes clusters and their prototypes

Parameters
[in]distance_matrixthe distance matrix of the elements to cluster
[in]preferencethe "preference" values that tells which elements are more likely to be cluster prototypes and that drives the number of cluster. The higher the values, the smaller the number of clusters.
[in]dampingthe damping rate. 0 = no damping, default = 0.5. The higher the value the slower the algorithm will converge. Low values may result in oscillations.
[in]stable_iters_stopnumber of consecutive identical clusterings to stop the algorithm (default = 10).
[in]max_itermaximum number of iterations (default = 100).
Returns
a pair containing in first the indexes of the cluster prototypes and in second the cluster number for each element.

Definition at line 178 of file CRNAffinityPropagation.cpp.

std::vector< double > crn::ComputeLOF ( const SquareMatrixDouble distmat,
size_t  k 
)

Compute the Local Outlier Factor for each element from the distance matrix.

Compute the Local Outlier Factor for each element from the distance matrix

Parameters
[in]distamata square matrix
[in]kthe size of the neighborhood
Exceptions
ExceptionDomaink<=1
ExceptionDimensiondistmat is not square
ExceptionLogick > distmat.size()
Returns
the list of LOFs

Definition at line 89 of file CRNOutliers.cpp.

std::vector< double > crn::ComputeLOF ( const std::vector< std::vector< double >> &  distmat,
size_t  k 
)

Compute the Local Outlier Factor for each element from the distance matrix.

Compute the Local Outlier Factor for each element from the distance matrix

Parameters
[in]distamata square matrix
[in]kthe size of the neighborhood
Exceptions
ExceptionDomaink<=1
ExceptionDimensiondistmat is not square
ExceptionLogick > distmat.size()
Returns
the list of LOFs

Definition at line 106 of file CRNOutliers.cpp.

std::vector< double > crn::ComputeLoOP ( const SquareMatrixDouble distmat,
size_t  k,
double  lambda 
)

compute the local outlier probability for each element from the distance matrix

Compute the Local Outlier Probability for each element from the distance matrix

Parameters
[in]distamata square matrix
[in]kthe size of the neighborhood
[in]lambdathe precision of the density estimation (lambda=1 -> 68%, 2 -> 95%, 3 -> 99.7%)
Exceptions
ExceptionDomaink<=1 or lambda<=0
ExceptionDimensiondistmat is not square
ExceptionLogick > distmat.size()
Returns
the list of LoOPs

Definition at line 182 of file CRNOutliers.cpp.

std::vector< double > crn::ComputeLoOP ( const std::vector< std::vector< double >> &  distmat,
size_t  k,
double  lambda 
)

compute the local outlier probability for each element from the distance matrix

Compute the Local Outlier Probability for each element from the distance matrix

Parameters
[in]distamata square matrix
[in]kthe size of the neighborhood
[in]lambdathe precision of the density estimation (lambda=1 -> 68%, 2 -> 95%, 3 -> 99.7%)
Exceptions
ExceptionDomaink<=1 or lambda<=0
ExceptionDimensiondistmat is not square
ExceptionLogick > distmat.size()
Returns
the list of LoOPs

Definition at line 200 of file CRNOutliers.cpp.

template<typename DATA , typename DISTANCE >
LazyDistanceMatrix<DATA, DISTANCE> crn::MakeLazyDistanceMatrix ( const std::vector< DATA > &  d,
DISTANCE &&  dist 
)
inline

Helper to avoid typing long type names.

Parameters
[in]dthe population
[in]distthe distance function
Returns
a distance matrix with lazy computation of distances

Definition at line 107 of file CRNLazyDistanceMatrix.h.

template<typename ITER , typename std::enable_if< std::is_copy_assignable< typename std::iterator_traits< ITER >::value_type >::value &&std::is_assignable< typename std::add_lvalue_reference< typename std::decay< typename std::iterator_traits< ITER >::value_type >::type >::type, int >::value &&traits::HasLT< typename std::iterator_traits< ITER >::value_type >::value &&IsVectorOverR< typename std::iterator_traits< ITER >::value_type >::value, int >::type = 0>
std::pair<typename std::iterator_traits<ITER>::value_type, typename std::iterator_traits<ITER>::value_type> crn::TwoMeans ( ITER  beg,
ITER  en,
double  stop_crit = 0.00001 
)

2-means clustering algorithm for scalar data

2-means clustering utility for scalar data.

Exceptions
ExceptionDomainthe range is empty
Parameters
[in]begiterator on the first element
[in]eniterator after the last element
[in]stop_critthe maximal difference between two iterations to stop the algorithm
Author
Yann LEYDIER
Date
Jul 2013
Version
0.1

Definition at line 60 of file CRN2Means.h.

template<typename ITER >
std::pair<typename std::iterator_traits<ITER>::value_type, typename std::iterator_traits<ITER>::value_type> crn::TwoMeans ( ITER  beg,
ITER  en,
typename std::iterator_traits< ITER >::value_type  p1,
typename std::iterator_traits< ITER >::value_type  p2,
double  stop_crit = 0.00001 
)
noexcept

2-means clustering algorithm for scalar data

2-means clustering utility for scalar data.

Exceptions
ExceptionDomainthe range is empty
Parameters
[in]begiterator on the first element
[in]eniterator after the last element
[in]p1first prototype
[in]p2first prototype
[in]stop_critthe maximal difference between two iterations to stop the algorithm
Author
Yann LEYDIER
Date
Jul 2013
Version
0.1

Definition at line 123 of file CRN2Means.h.