Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

CDistanceMachine Class Reference


Detailed Description

A generic DistanceMachine interface.

A distance machine is based on a a-priori choosen distance.

Definition at line 32 of file DistanceMachine.h.

Inheritance diagram for CDistanceMachine:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CDistanceMachine ()
virtual ~CDistanceMachine ()
void set_distance (CDistance *d)
CDistanceget_distance ()
void distances_lhs (float64_t *result, int32_t idx_a1, int32_t idx_a2, int32_t idx_b)
void distances_rhs (float64_t *result, int32_t idx_b1, int32_t idx_b2, int32_t idx_a)
virtual const char * get_name (void) const
virtual CLabelsapply ()
virtual CLabelsapply (CFeatures *data)
virtual float64_t apply (int32_t num)

Protected Member Functions

virtual void store_model_features ()

Static Protected Member Functions

static void * run_distance_thread_lhs (void *p)
static void * run_distance_thread_rhs (void *p)

Protected Attributes

CDistancedistance

Constructor & Destructor Documentation

default constructor

Definition at line 28 of file DistanceMachine.cpp.

~CDistanceMachine (  )  [virtual]

Definition at line 34 of file DistanceMachine.cpp.


Member Function Documentation

CLabels * apply (  )  [virtual]

Classify all rhs features using the built clusters. Cluster index with smallest distance to to be classified element is returned

Returns:
classified labels

Implements CMachine.

Reimplemented in CKNN, and CHierarchical.

Definition at line 224 of file DistanceMachine.cpp.

float64_t apply ( int32_t  num  )  [virtual]

Apply machine to one example. Cluster index with smallest distance to to be classified element is returned

Parameters:
num which example to apply machine to
Returns:
cluster label nearest to example

Reimplemented from CMachine.

Reimplemented in CKNN, and CHierarchical.

Definition at line 233 of file DistanceMachine.cpp.

CLabels * apply ( CFeatures data  )  [virtual]

Classify all provided features. Cluster index with smallest distance to to be classified element is returned

Parameters:
data (test)data to be classified
Returns:
classified labels

Implements CMachine.

Reimplemented in CKNN, and CHierarchical.

Definition at line 207 of file DistanceMachine.cpp.

void distances_lhs ( float64_t result,
int32_t  idx_a1,
int32_t  idx_a2,
int32_t  idx_b 
)

get distance functions for lhs feature vectors going from a1 to a2 and rhs feature vector b

Parameters:
result array of distance values
idx_a1 first feature vector a1 at idx_a1
idx_a2 last feature vector a2 at idx_a2
idx_b feature vector b at idx_b

Definition at line 51 of file DistanceMachine.cpp.

void distances_rhs ( float64_t result,
int32_t  idx_b1,
int32_t  idx_b2,
int32_t  idx_a 
)

get distance functions for rhs feature vectors going from b1 to b2 and lhs feature vector a

Parameters:
result array of distance values
idx_b1 first feature vector a1 at idx_b1
idx_b2 last feature vector a2 at idx_b2
idx_a feature vector a at idx_a

Definition at line 113 of file DistanceMachine.cpp.

CDistance* get_distance (  ) 

get distance

Returns:
distance

Definition at line 54 of file DistanceMachine.h.

virtual const char* get_name ( void   )  const [virtual]

Returns the name of the SGSerializable instance. It MUST BE the CLASS NAME without the prefixed `C'.

Returns:
name of the SGSerializable

Implements CSGObject.

Reimplemented in CKNN, CHierarchical, and CKMeans.

Definition at line 83 of file DistanceMachine.h.

void * run_distance_thread_lhs ( void *  p  )  [static, protected]

pthread function for compute distance values

Parameters:
p thread parameter

Definition at line 175 of file DistanceMachine.cpp.

void * run_distance_thread_rhs ( void *  p  )  [static, protected]

pthread function for compute distance values

Parameters:
p thread parameter

Definition at line 191 of file DistanceMachine.cpp.

void set_distance ( CDistance d  ) 

set distance

Parameters:
d distance to set

Definition at line 43 of file DistanceMachine.h.

virtual void store_model_features (  )  [protected, virtual]

Ensures cluster centers are in lhs of underlying distance

NOT IMPLEMENTED! Base method. Is called automatically after train because flag is always true for distance machines. Since every distance machine has to make sure that cluster centers are in lhs of distance variable, it is unimplemented here and HAS to be implemented in subclasses.

Reimplemented from CMachine.

Reimplemented in CKNN, CHierarchical, and CKMeans.

Definition at line 121 of file DistanceMachine.h.


Member Data Documentation

CDistance* distance [protected]

the distance

Definition at line 146 of file DistanceMachine.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation