Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::ProximityMatrix Class Reference

#include <ProximityMatrix.h>

Inheritance diagram for prapi::ProximityMatrix:

Matrix< T > Object List of all members.

Detailed Description

ProximityMatrix calculates the distances between all pairs of samples and places the results in a double-valued matrix.

It can use any proximity measure and it is able to treat both symmetric and non-symmetric measures. The complexity of this process is O(N2), where N is the number of samples.

Where can it be used, then? There are situations when you might want to scale your proximity measures using the mean or variance of measured distances between samples. This is needed when you have many feature vectors for each sample. Here is how to do the scaling:

 //Let us suppose we have two feature vectors for each sample.
 //MyProximityMeasure is inherited from ProximityMeasure<int>
 MyProximityMeasure measure1, measure2;
 List<Sample<List<int> > > samples;
 //Create the samples somehow.

 //Create a multi-feature proximity measure
 List<ProximityMeasure<int>* > measures;
 measures += &measure1;
 measures += &measure2;

 ProximityCombiner::WeightedSum combiner;
 MultiFeatureProximity<int> mfpm(measures,combiner);

 //First calculate scaling for the first feature vector
 mfpm.setEnabled(1,false);
 ProximityMatrix mat(mfpm, samples);
 //Scale the proximities for the first feature vector by
 //the variance of all proximities
 combiner.setWeight(0,1.0/util::Math<double>variance(mat));

 mfpm.setEnabled(1,true);
 mfpm.setEnabled(0,false);
 ProximityMatrix mat2(mfpm, samples);
 combiner.setWeight(1,1.0/util::Math<double>variance(mat2));
 mfpm.setEnabled(1,true);

 //Now, you have a multi-feature proximity measure (mfpm) that
 //scales the proximities for each feature vector by the
 //variance of all proximities.
 

See also:
util::Math , MultiFeatureProximityMeasure , ProximityCombiner


Public Methods

 ProximityMatrix ()
 Default constructor.

 ProximityMatrix (const ProximityMatrix &other)
 Copy constructor.

 ProximityMatrix (const Matrix< double > &other)
 Copy constructor for double matrices.

ProximityMatrix & operator= (const ProximityMatrix &other)
 Assignment operator.

ProximityMatrix & operator= (const Matrix< double > &other)
 Assignment operator for double matrices.

template<class T, class I, class C>  ProximityMatrix (ProximityMeasure< T > &measure, List< Sample< T, I, C > > &samples)
 Create a proximity matrix out of the given samples using the given proximity measure.

template<class T, class I, class C>  ProximityMatrix (ProximityMeasure< T > &measure, List< Sample< List< T >, I, C > > &samples, int featureIndex)
 Create a proximity matrix for a given feature from a list of multi-feature samples.


Static Public Methods

template<class T, class I, class C> List< ProximityMatrix > generateMatrices (List< ProximityMeasure< T > * > &measures, List< Sample< List< T >, I, C > > &samples) throw (InvalidArgumentException&)
 Generate a list of proximity matrices out of the given multi-feature samples.


Constructor & Destructor Documentation

template<class T, class I, class C>
prapi::ProximityMatrix::ProximityMatrix ProximityMeasure< T > &    measure,
List< Sample< T, I, C > > &    samples
 

Create a proximity matrix out of the given samples using the given proximity measure.

Parameters:
measure  the proximity measure
samples  calculate the distances between these samples. The size of the resulting matrix will be NxN, where N is the length of the sample list.

template<class T, class I, class C>
prapi::ProximityMatrix::ProximityMatrix ProximityMeasure< T > &    measure,
List< Sample< List< T >, I, C > > &    samples,
int    featureIndex
 

Create a proximity matrix for a given feature from a list of multi-feature samples.

Parameters:
measure  the proximity measure to be used for the feature vector
samples  calculate the distances between these samples. The size of the resulting matrix will be NxN, where N is the length of the sample list.
featureIndex  the index of the feature to be considered


Member Function Documentation

template<class T, class I, class C>
List< ProximityMatrix > prapi::ProximityMatrix::generateMatrices List< ProximityMeasure< T > * > &    measures,
List< Sample< List< T >, I, C > > &    samples
throw (InvalidArgumentException&) [static]
 

Generate a list of proximity matrices out of the given multi-feature samples.

A proximity matrix is created for each feature vector.

Example:

 MyProximityMeasure measure1, measure2;
 List<Sample<List<int> > > samples;
 //Create the samples somehow.

 List<ProximityMeasure<int>*> measures;
 measures += &measure1;
 measures += &measure2;

 List<ProximityMatrix> matrices(ProximityMatrix::generateMatrices(measures,samples));
 //Look at the previous code samples for information on how the matrices
 //can be utilized.
 
Parameters:
measures  a list of proximity measures for the corresponding feature vectors.
samples  the samples


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.