IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
KMeansClustering.h
1 // KMeansClustering.h:
3 // -------------------
4 //
21 
22 #ifndef __IPSDKMATH_KMEANSCLUSTERING_H__
23 #define __IPSDKMATH_KMEANSCLUSTERING_H__
24 
25 // suppression warnings
26 // warning C4251: 'ipsdk::math::clustering::KMeansClustering::_inputDataColl': class 'std::vector<ipsdk::math::Vector,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'ipsdk::math::clustering::KMeansClustering'
27 // warning C4275: interface non dll class 'boost::noncopyable_::noncopyable' utilisée comme base d'une interface dll class 'ipsdk::math::clustering::KMeansClustering'
28 #pragma warning (push)
29 #pragma warning (disable : 4275 4251)
30 
33 #include <IPSDKMath/Clustering/KMeansClusteringConfig.h>
34 #include <boost/noncopyable.hpp>
35 
36 namespace ipsdk {
37 namespace math {
38 namespace clustering {
39 
42 
43 class IPSDKMATH_API KMeansClustering : public boost::noncopyable
44 {
45 // predefined public types
46 public:
49 
50 public:
56 
57 // methods
58 public:
61  const AlgorithmConfig& getConfig() const;
62  void setConfig(const AlgorithmConfig& config);
64 
65  // ----------------------------
68  // ----------------------------
69 
71  bool isClusteringDone() const;
72 
96  bool compute(const ipUInt32 nbClusters,
97  const VectorColl& inputDataColl);
99 
100  // ------------------------
103  // ------------------------
104 
108  ipUInt32 getNbClusters() const;
109 
113  ipUInt32 getDataSize() const;
114 
118  ipUInt32 getNbInputData() const;
119 
123  const VectorColl& getInputDataColl() const;
124 
128  ipUInt32 getNbFailedAttempts() const;
129 
136  ipReal64 getCompactness() const;
137 
142  ipUInt32 getNbIteration() const;
143 
147  ipReal64 computeValidityIndex(const eValidityIndexType& validityIndexType) const;
148 
152  const VectorColl& getClustersCenters() const;
153 
157  ipUInt32 getClusterPopulation(const ipUInt32 clusterIdx) const;
158 
162  const Vector& getClusterCenter(const ipUInt32 clusterIdx) const;
163 
167  ipReal64 getClusterStdDev(const ipUInt32 clusterIdx) const;
168 
172  const UInt32Vector& getAssignments() const;
173 
179  ipUInt32 computeAssignment(const Vector& data) const;
181 
183  void clear();
184 
185 // attributes
186 protected:
189 
192 
195 
198 
201 
204 
207 };
208 
211 
212 } // end of namespace clustering
213 } // end of namespace math
214 } // end of namespace ipsdk
215 
216 #pragma warning (pop)
217 
218 #endif // __IPSDKMATH_KMEANSCLUSTERING_H__
Definition of import/export macro for library.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
std::vector< ipUInt32 > UInt32Vector
stl vector collections
Definition: BaseCollections.h:33
UInt32Vector _assignments
cluster index associated to each input data
Definition: KMeansClustering.h:206
ipUInt32 _nbIteration
number of iterations associated to selected clustering solution
Definition: KMeansClustering.h:197
eValidityIndexType
Enumerate describing a clustering validity indice type.
Definition: ClusteringTypes.h:48
ipUInt32 _nbFailedAttempts
number of failed attempts
Definition: KMeansClustering.h:194
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
Definition: KMeansClusteringConfig.h:28
std::vector< Vector > VectorColl
collection of vectors
Definition: ClusteringTypes.h:31
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
KMeansClusteringConfig AlgorithmConfig
algorithm configuration
Definition: KMeansClustering.h:48
Definition: KMeansClustering.h:43
AlgorithmConfig _config
configuration associated to clustering algorithm
Definition: KMeansClustering.h:188
VectorColl _clustersCenters
cluster centers associated to processing
Definition: KMeansClustering.h:203
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 ...
ipReal64 _compactness
compactness associated to processing
Definition: KMeansClustering.h:200
Predefined types for clustering algorithm.
VectorColl _inputDataColl
input data collection
Definition: KMeansClustering.h:191
uint32_t ipUInt32
Base types definition.
Definition: BaseTypes.h:53