Loading...
Searching...
No Matches
te::cl::KMeans< TTRAIN, TCLASSIFY > Class Template Reference

KMeans strategy for classification. Step-by-step: More...

#include <KMeans.h>

Classes

class  Parameters
 Classifier Parameters. More...
 

Public Member Functions

bool classify (TCLASSIFY &itBegin, TCLASSIFY &itEnd, const std::vector< unsigned int > &attributesIndices, std::vector< unsigned int > &classification, const bool enableProgressInterface)
 
bool initialize (const Parameters &params)
 
 KMeans ()
 
bool train (TTRAIN &itBegin, TTRAIN &itEnd, const std::vector< unsigned int > &attributesIndices, const std::vector< unsigned int > &labels, const bool enableProgressInterface)
 
 ~KMeans ()
 

Protected Member Functions

unsigned int getClassification (std::vector< double > values)
 

Protected Attributes

bool m_isInitialized
 True if this instance is initialized.
 
std::vector< std::vector< double > > m_KMeans
 The vector of K means.
 
Parameters m_parameters
 Internal execution parameters.
 

Detailed Description

template<class TTRAIN, class TCLASSIFY>
class te::cl::KMeans< TTRAIN, TCLASSIFY >

KMeans strategy for classification. Step-by-step:

  1. Define a random solution, creating K values of mean.
  2. Classify each input value according to the closest mean.
  3. Calculate new means using the classified pixels.
  4. Go back to step 2, or stop depending on the following checks: 4.1. Check if the new means are different from the previous iteration, using the convergence threshold. 4.2. Check if maximum number of iterations has achieved.
    Note
    Output classification IDs starting at 1.

Definition at line 63 of file KMeans.h.

Constructor & Destructor Documentation

◆ KMeans()

template<class TTRAIN, class TCLASSIFY>
te::cl::KMeans< TTRAIN, TCLASSIFY >::KMeans ( )

Definition at line 164 of file KMeans.h.

References m_isInitialized, and m_KMeans.

◆ ~KMeans()

template<class TTRAIN, class TCLASSIFY>
te::cl::KMeans< TTRAIN, TCLASSIFY >::~KMeans ( )

Definition at line 171 of file KMeans.h.

Member Function Documentation

◆ classify()

template<class TTRAIN, class TCLASSIFY>
bool te::cl::KMeans< TTRAIN, TCLASSIFY >::classify ( TCLASSIFY & itBegin,
TCLASSIFY & itEnd,
const std::vector< unsigned int > & attributesIndices,
std::vector< unsigned int > & classification,
const bool enableProgressInterface )

◆ getClassification()

template<class TTRAIN, class TCLASSIFY>
unsigned int te::cl::KMeans< TTRAIN, TCLASSIFY >::getClassification ( std::vector< double > values)
protected

Definition at line 353 of file KMeans.h.

References te::cl::GetEuclideanDistance(), m_KMeans, and m_parameters.

Referenced by classify(), and train().

◆ initialize()

template<class TTRAIN, class TCLASSIFY>
bool te::cl::KMeans< TTRAIN, TCLASSIFY >::initialize ( const Parameters & params)

Definition at line 176 of file KMeans.h.

References m_isInitialized, m_KMeans, m_parameters, and TE_TR.

◆ train()

template<class TTRAIN, class TCLASSIFY>
bool te::cl::KMeans< TTRAIN, TCLASSIFY >::train ( TTRAIN & itBegin,
TTRAIN & itEnd,
const std::vector< unsigned int > & attributesIndices,
const std::vector< unsigned int > & labels,
const bool enableProgressInterface )

Member Data Documentation

◆ m_isInitialized

template<class TTRAIN, class TCLASSIFY>
bool te::cl::KMeans< TTRAIN, TCLASSIFY >::m_isInitialized
protected

True if this instance is initialized.

Definition at line 116 of file KMeans.h.

Referenced by initialize(), and KMeans().

◆ m_KMeans

template<class TTRAIN, class TCLASSIFY>
std::vector<std::vector<double> > te::cl::KMeans< TTRAIN, TCLASSIFY >::m_KMeans
protected

The vector of K means.

Definition at line 117 of file KMeans.h.

Referenced by getClassification(), initialize(), KMeans(), and train().

◆ m_parameters

template<class TTRAIN, class TCLASSIFY>
Parameters te::cl::KMeans< TTRAIN, TCLASSIFY >::m_parameters
protected

Internal execution parameters.

Definition at line 118 of file KMeans.h.

Referenced by getClassification(), initialize(), and train().


The documentation for this class was generated from the following file: