Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::Cumlog< T > Class Template Reference

#include <ProximityMeasure.h>

Inheritance diagram for prapi::Cumlog< T >:

prapi::ProximityMeasure< T > Object List of all members.

Detailed Description

template<class T = double>
class prapi::Cumlog< T >

Cumlog is a log-likelihood proximity measure.

It is defined as C = -sumi=1..N(Siln(Mi)), where S and M represent the sample and model distributions, respectively. N is the length of the distributions. If the normalization flag is set to true, M and S are normalized prior to distance calculation.

Cumlog is an asymmetric proximity measure, i.e. P(a,b) is generally different from P(b,a).


Public Methods

 Cumlog (double minValue=1e-8, bool normalized=true)
 Construct a new cumlog proximity measure.

 ~Cumlog ()
 Destroy the measure.

void setMinValue (double value) throw (InvalidArgumentException&)
 Set the minimum value for a distribution entry that will be encountered.

double getMinValue (void) const
 Get the minimum value that is substituted to zero-valued feature vector entries.

void setNormalized (bool normalize)
 Set the normalized state.

bool isNormalized (void) const
 Get the normalize state.

double getProximity (const util::List< T > &sample, const util::List< T > &model, double stopAfter=MAXDOUBLE) const throw (ProximityException&)
 Proximity between two lists.

void createLookupTable (int maxValue)
 To speed up the calculation of the log-likelihood measure, one may think of using a look-up table instead of the on-line calculation.

void releaseLookupTable ()
 Release the look-up table.


Constructor & Destructor Documentation

template<class T = double>
prapi::Cumlog< T >::Cumlog double    minValue = 1e-8,
bool    normalized = true
[inline]
 

Construct a new cumlog proximity measure.

The measure is set to use cluster representatives.

Parameters:
minValue  the minimum value for a histogram bin (1.0 means that zero bins are simply discarded because log(1.0)=0).
normalized  the normalization flag

template<class T = double>
prapi::Cumlog< T >::~Cumlog   [inline]
 

Destroy the measure.

If there is a look-up table, it will be destroyed as well.


Member Function Documentation

template<class T>
void prapi::Cumlog< T >::createLookupTable int    maxValue
 

To speed up the calculation of the log-likelihood measure, one may think of using a look-up table instead of the on-line calculation.

If you know that the values in your samples will never exceed a certain maximum value, then a look-up table of finite size can be created. For example, when creating a histogram out of 32x32 images, there will never be a value greater than 1024 (or smaller than 0). There are thus 1025 distinct values, and the look-up table will contain 1025x1025 entries. Alternatively, you may use the look-up table with normalized feature values. Each feature vector element is assumed to be in the range [0,1]. The values are multiplied by the given maximum value, rounded to the closest integer and used as a look-up table index.

Once created, the look-up table will be used for all subsequent proximity calculations. If you want to return to the on-line calculation mode, call releaseLookupTable(). Note that with normalized features, the proximity calculation is "quantized", resulting in somewhat more inaccurate proximity calculations.

Parameters:
maxValue  the maximum value a feature can attain.

template<class T>
double prapi::Cumlog< T >::getProximity const util::List< T > &    sample,
const util::List< T > &    model,
double    stopAfter = MAXDOUBLE
const throw (ProximityException&) [virtual]
 

Proximity between two lists.

Parameters:
sample  the list to be classified
model  the model
stopAfter  A value that can be used in optimizing the performance of a proximity measure. Classifiers may set this value to inform the proximity measure to stop if it notices the proximity will be over a certain value. For example, the kNN classifier sets this value to the kth smallest proximity so far. If a sample is not closer than that, then it makes no sense to inspect it any more.

Implements prapi::ProximityMeasure< T >.

template<class T = double>
void prapi::Cumlog< T >::releaseLookupTable   [inline]
 

Release the look-up table.

All subsequent proximity calculations will be made on-line.

template<class T = double>
void prapi::Cumlog< T >::setMinValue double    value throw (InvalidArgumentException&) [inline]
 

Set the minimum value for a distribution entry that will be encountered.

All zeros in model histograms will be replaced with this value in proximity calculations. (Because otherwise a logarithm of zero would be calculated.) The default value is 10-8. Setting this value is particularty important with sparse distributions. If your distribution is a histogram calculated from an matrix, you may want to set this value to 1/(rows*cols).

Exceptions:
InvalidArgumentException  & if value is smaller than or equal to zero.

template<class T = double>
void prapi::Cumlog< T >::setNormalized bool    normalize [inline]
 

Set the normalized state.

If true, then all feature vectors given to this proximity measure are normalized prior to calculating the proximity. If false, then the feature vectors are assumed to be normalized a priori. In the latter case, the computational performance of the measure will be significantly higher. The default value is true.


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.