Sleipnir
Public Types | Public Member Functions
Sleipnir::IMeasure Class Reference

Encapsulates any similarity (or occasionally distance) measure operating over two vectors. More...

#include <measure.h>

Inheritance diagram for Sleipnir::IMeasure:
Sleipnir::CMeasureAutocorrelate Sleipnir::CMeasureBinaryInnerProduct Sleipnir::CMeasureDice Sleipnir::CMeasureDistanceCorrelation Sleipnir::CMeasureEuclidean Sleipnir::CMeasureEuclideanScaled Sleipnir::CMeasureHypergeometric Sleipnir::CMeasureInnerProduct Sleipnir::CMeasureInvert Sleipnir::CMeasureKendallsTau Sleipnir::CMeasureKolmogorovSmirnov Sleipnir::CMeasureMutualInformation Sleipnir::CMeasureNegate Sleipnir::CMeasurePearNorm Sleipnir::CMeasurePearson Sleipnir::CMeasurePearsonSignificance Sleipnir::CMeasureQuickPearson Sleipnir::CMeasureRelativeAUC Sleipnir::CMeasureSigmoid Sleipnir::CMeasureSignedDistanceCorrelation Sleipnir::CMeasureSpearman

Public Types

enum  EMap { EMapNone = 0, EMapCenter = EMapNone + 1, EMapAbs = EMapCenter + 1 }
 Indicates how the result of a measure should be centered. More...

Public Member Functions

virtual const char * GetName () const =0
 Return the human-readable unique identifier of the measure type.
virtual bool IsRank () const =0
 Return true if the measure requires rank-based integer inputs.
virtual IMeasureClone () const =0
 Create a copy of the current measure object.
virtual double Measure (const float *adX, size_t iN, const float *adY, size_t iM, EMap eMap=EMapNone, const float *adWX=NULL, const float *adWY=NULL) const =0
 Calculate the measure between two given vectors with optional element weights.

Detailed Description

Encapsulates any similarity (or occasionally distance) measure operating over two vectors.

IMeasures are generally similarity measures consuming two floating point vectors and producing a single continuous result. There are a few distance measures implemented, but since everything in Sleipnir assumes measures to be similarity-based (i.e. higher is closer), several IMeasures exist to reverse distance measures (e.g. CMeasureNegate and CMeasureInvert).

Most measures require input vectors of the same length, but some don't; likewise, most measures will ignore weights for the vector elements if they're provided, but some won't. Most measures will deal appropriately with missing values (NaNs) in their inputs. Many measures support different forms of centering, although some will ignore centering and return the raw measure value. For more information, see EMap.

Remarks:
Most measure objects don't actually use any memory, but a few do, depending on their implementation, and care should be taken to manage memory for these appropriately. The Clone method exists to allow a measure to copy itself without breaking the interface, and most measures that require memory management take a constructor argument indicating whether they are responsible for freeing memory references.

Definition at line 52 of file measure.h.


Member Enumeration Documentation

Indicates how the result of a measure should be centered.

Enumerator:
EMapNone 

Perform no centering and return the original measure result.

EMapCenter 

Center the measure result by scaling to the range [0, 1].

EMapAbs 

Return the absolute value of the original measure result.

Definition at line 58 of file measure.h.


Member Function Documentation

virtual IMeasure* Sleipnir::IMeasure::Clone ( ) const [pure virtual]
virtual const char* Sleipnir::IMeasure::GetName ( ) const [pure virtual]
virtual bool Sleipnir::IMeasure::IsRank ( ) const [pure virtual]
virtual double Sleipnir::IMeasure::Measure ( const float *  adX,
size_t  iN,
const float *  adY,
size_t  iM,
EMap  eMap = EMapNone,
const float *  adWX = NULL,
const float *  adWY = NULL 
) const [pure virtual]

Calculate the measure between two given vectors with optional element weights.

Parameters:
adXFirst array of values.
iNLength of first array.
adYSecond array of values.
iMLength of second array.
eMapWay in which returned value should be centered (implementation-specific).
adWXIf non-null, weights of elements in the first array.
adWYIf non-null, weights of elements in the second array.
Returns:
Measure calculated between the two input vectors and, optionally, weights.
Remarks:
Pretty much every implementation will puke if given bad input; bounds checking etc. is minimal.

Implemented in Sleipnir::CMeasureDice, Sleipnir::CMeasureSignedDistanceCorrelation, Sleipnir::CMeasureDistanceCorrelation, Sleipnir::CMeasurePearsonSignificance, Sleipnir::CMeasureRelativeAUC, Sleipnir::CMeasureMutualInformation, Sleipnir::CMeasureBinaryInnerProduct, Sleipnir::CMeasureInnerProduct, Sleipnir::CMeasureHypergeometric, Sleipnir::CMeasurePearNorm, Sleipnir::CMeasureSpearman, Sleipnir::CMeasureKendallsTau, Sleipnir::CMeasureKolmogorovSmirnov, Sleipnir::CMeasureQuickPearson, Sleipnir::CMeasurePearson, Sleipnir::CMeasureEuclideanScaled, Sleipnir::CMeasureEuclidean, Sleipnir::CMeasureAutocorrelate, Sleipnir::CMeasureInvert, Sleipnir::CMeasureNegate, and Sleipnir::CMeasureSigmoid.

Referenced by Sleipnir::CClustKMeans::Cluster(), Sleipnir::CPCL::Distance(), Sleipnir::CPCL::Impute(), Sleipnir::CMeasureSigmoid::Measure(), Sleipnir::CMeasureNegate::Measure(), Sleipnir::CMeasureInvert::Measure(), Sleipnir::CMeasureAutocorrelate::Measure(), and Sleipnir::CDatasetCompact::Open().


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