#include <ProximityMatrix.h>
Inheritance diagram for prapi::ProximityMatrix:

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.
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. | |
|
||||||||||||||||
|
Create a proximity matrix out of the given samples using the given proximity measure.
|
|
||||||||||||||||||||
|
Create a proximity matrix for a given feature from a list of multi-feature samples.
|
|
||||||||||||||||
|
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.
|