IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
ClusteringUtils.h
Go to the documentation of this file.
1 // ClusteringUtils.h:
3 // ------------------
4 //
14 
15 #ifndef __IPSDKMATH_CLUSTERINGUTILS_H__
16 #define __IPSDKMATH_CLUSTERINGUTILS_H__
17 
20 #include <iostream>
21 
22 namespace ipsdk {
23 namespace math {
24 namespace clustering {
25 
26 template <typename KernelType>
28 
31 
36 computeCompactness(const VectorColl& clustersCentersColl,
37  const VectorColl& dataColl,
38  const UInt32Vector& indexColl);
39 
43 template <typename KernelType>
45 computeKernelCompactness(const std::vector<KernelKMeansCentroid<KernelType> >& clustersCentroids,
46  const VectorColl& dataColl,
47  const UInt32Vector& indexColl);
48 
57 computeValidityIndex(const VectorColl& clustersCentersColl,
58  const VectorColl& dataColl,
59  const UInt32Vector& indexColl,
60  const eValidityIndexType& validityIndexType);
61 
67 IPSDKMATH_API void
68 generateKMeansPPInit(const ipUInt32 nbClusters,
69  const VectorColl& inputDataColl,
70  VectorColl& initClustersCenters);
71 
77 template <typename KernelType>
78 IPSDKMATH_API void
79 generateKernelKMeansPPInit(const KernelType& kernel,
80  const ipUInt32 nbClusters,
81  const VectorColl& inputDataColl,
82  VectorColl& initClustersCenters);
83 
88 computeAssignment(const VectorColl& clustersCentersColl,
89  const Vector& data);
90 
95 computeKMeansAttempt(const VectorColl& inputDataColl,
96  const ipUInt32 nbMaxIteration,
97  VectorColl& inOutClustersCenters,
98  UInt32Vector& assignments);
99 
103 template <typename KernelType>
105 computeKernelAssignment(const std::vector<KernelKMeansCentroid<KernelType> >& clustersCentroids,
106  const Vector& data);
107 
111 template <typename KernelType>
113 computeKernelKMeansAttempt(const KernelType& kernel,
114  const VectorColl& inputDataColl,
115  const ipUInt32 nbMaxIteration,
116  const ipReal64 minChangeRatio,
117  std::vector<KernelKMeansCentroid<KernelType> >& inOutClustersCentroids,
118  UInt32Vector& assignments);
119 
123 IPSDKMATH_API void
124 computeClustersCenters(const ipUInt32 nbClusters,
125  const VectorColl& inputDataColl,
126  const UInt32Vector& indexColl,
127  VectorColl& clustersCentersColl);
128 
133 computeClusterPopulation(const ipUInt32 clusterIdx,
134  const UInt32Vector& indexColl);
135 
140 computeClusterCenter(const ipUInt32 clusterIdx,
141  const VectorColl& inputDataColl,
142  const UInt32Vector& indexColl);
143 
148 computeClusterStdDev(const ipUInt32 clusterIdx,
149  const VectorColl& inputDataColl,
150  const UInt32Vector& indexColl,
151  const Vector& clusterCenter);
152 
158 radialBasisKernelSigmaFromDynamic(const VectorColl& inputDataColl,
159  const ipReal64 ratio = 0.2);
160 
162 IPSDKMATH_API std::ostream&
163 operator<< (std::ostream& os,
164  const KMeansClustering& clustering);
165 
167 template <typename KernelType>
168 IPSDKMATH_API std::ostream&
169 operator<< (std::ostream& os,
170  const KernelKMeansClustering<KernelType>& clustering);
171 
173 template <typename KernelType>
174 IPSDKMATH_API std::ostream&
175 operator<< (std::ostream& os,
176  const SpectralClustering<KernelType>& clustering);
177 
180 
181 } // end of namespace clustering
182 } // end of namespace math
183 } // end of namespace ipsdk
184 
185 #endif // __IPSDKMATH_CLUSTERINGUTILS_H__
IPSDKMATH_API Vector computeClusterCenter(const ipUInt32 clusterIdx, const VectorColl &inputDataColl, const UInt32Vector &indexColl)
function allowing to compute center associated to a given cluster
Definition of import/export macro for library.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
IPSDKMATH_API ipUInt32 computeKernelAssignment(const std::vector< KernelKMeansCentroid< KernelType > > &clustersCentroids, const Vector &data)
function allowing to compute cluster assignment using an kernel distance to clusters centroids ...
IPSDKMATH_API ipUInt32 computeClusterPopulation(const ipUInt32 clusterIdx, const UInt32Vector &indexColl)
function allowing to compute population associated to a given cluster
std::vector< ipUInt32 > UInt32Vector
stl vector collections
Definition: BaseCollections.h:33
IPSDKMATH_API ipReal64 computeKernelCompactness(const std::vector< KernelKMeansCentroid< KernelType > > &clustersCentroids, const VectorColl &dataColl, const UInt32Vector &indexColl)
function allowing to compute compactness associated to a Kernel clustering result ...
eValidityIndexType
Enumerate describing a clustering validity indice type.
Definition: ClusteringTypes.h:48
Definition: ClusteringUtils.h:27
IPSDKMATH_API void generateKernelKMeansPPInit(const KernelType &kernel, const ipUInt32 nbClusters, const VectorColl &inputDataColl, VectorColl &initClustersCenters)
function allowing to generate an initial solution for Kernel K-Means algorithm using K-Means++ approa...
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Definition: ClusteringTypes.h:31
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
IPSDKMATH_API ipReal64 computeCompactness(const VectorColl &clustersCentersColl, const VectorColl &dataColl, const UInt32Vector &indexColl)
function allowing to compute compactness associated to a clustering result
std::vector< Vector > VectorColl
collection of vectors
Definition: ClusteringTypes.h:31
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
Definition: KMeansClustering.h:43
IPSDKMATH_API ipReal64 computeClusterStdDev(const ipUInt32 clusterIdx, const VectorColl &inputDataColl, const UInt32Vector &indexColl, const Vector &clusterCenter)
function allowing to compute standard deviation associated to a given cluster
IPSDKMATH_API ipUInt32 computeKernelKMeansAttempt(const KernelType &kernel, const VectorColl &inputDataColl, const ipUInt32 nbMaxIteration, const ipReal64 minChangeRatio, std::vector< KernelKMeansCentroid< KernelType > > &inOutClustersCentroids, UInt32Vector &assignments)
function allowing to compute a kernel kmeans attempt from an initial solution
IPSDKMATH_API ipUInt32 computeKMeansAttempt(const VectorColl &inputDataColl, const ipUInt32 nbMaxIteration, VectorColl &inOutClustersCenters, UInt32Vector &assignments)
function allowing to compute a kmeans attempt from an initial solution
IPSDKMATH_API std::ostream & operator<<(std::ostream &os, const EstimationConfig &config)
output operator on EstimationConfig
IPSDKMATH_API ipReal64 computeValidityIndex(const VectorColl &clustersCentersColl, const VectorColl &dataColl, const UInt32Vector &indexColl, const eValidityIndexType &validityIndexType)
function allowing to compute a validity index of a clustering
IPSDKMATH_API ipUInt32 computeAssignment(const VectorColl &clustersCentersColl, const Vector &data)
function allowing to compute cluster assignment using an euclidian distance to clusters centers ...
Predefined types for clustering algorithm.
IPSDKMATH_API void generateKMeansPPInit(const ipUInt32 nbClusters, const VectorColl &inputDataColl, VectorColl &initClustersCenters)
function allowing to generate an initial solution for K-Means algorithm using K-Means++ approach ...
Definition: ClusteringTypes.h:29
IPSDKMATH_API void computeClustersCenters(const ipUInt32 nbClusters, const VectorColl &inputDataColl, const UInt32Vector &indexColl, VectorColl &clustersCentersColl)
function allowing to compute clusters centers given data assignments using mean computation ...
IPSDKMATH_API ipReal64 radialBasisKernelSigmaFromDynamic(const VectorColl &inputDataColl, const ipReal64 ratio=0.2)
function allowing to compute a sigma value used for radial basis kernel computations based on input d...
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53