GClasses
GClasses::GLNormDistance Class Reference

Detailed Description

Interpolates between manhattan distance (norm=1), Euclidean distance (norm=2), and Chebyshev distance (norm=infinity). For nominal attributes, Hamming distance is used.

#include <GDistance.h>

Inheritance diagram for GClasses::GLNormDistance:
GClasses::GDistanceMetric

Public Member Functions

 GLNormDistance (double norm)
 
 GLNormDistance (GDomNode *pNode)
 
virtual ~GLNormDistance ()
 
virtual void init (const GRelation *pRelation, bool own)
 See the comment for GDistanceMetric::init. More...
 
virtual const char * name () const
 Returns the name of this class. More...
 
virtual GDomNodeserialize (GDom *pDoc) const
 See the comment for GDistanceMetric::serialize. More...
 
void setDiffWithUnknown (double d)
 Specify the difference to use when one or more of the values is unknown. (If your data contains unknown values, you may want to normalize the known values to fall within some pre-determined range, so that it will be possible to select a reasonable value for this purpose.) More...
 
virtual double squaredDistance (const GVec &a, const GVec &b) const
 Returns the distance (using the norm passed to the constructor) between pA and pB. More...
 
- Public Member Functions inherited from GClasses::GDistanceMetric
 GDistanceMetric ()
 
 GDistanceMetric (GDomNode *pNode)
 
virtual ~GDistanceMetric ()
 
double operator() (const GVec &a, const GVec &b) const
 Return squaredDistance(pA, pB). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(pA,pB) instead. See GDistanceMetric::squaredDistance(const GVec&, const GVec&) More...
 
const GRelationrelation () const
 Returns the relation that specifies the meaning of the vector elements. More...
 
virtual GVecscaleFactors ()
 Returns a reference to the vector of attribute scalars. More...
 

Protected Attributes

double m_diffWithUnknown
 
double m_norm
 
- Protected Attributes inherited from GClasses::GDistanceMetric
bool m_ownRelation
 
const GRelationm_pRelation
 
GVec m_scaleFactors
 

Additional Inherited Members

- Static Public Member Functions inherited from GClasses::GDistanceMetric
static GDistanceMetricdeserialize (GDomNode *pNode)
 Deserializes a distance metric. More...
 
static void test ()
 
- Protected Member Functions inherited from GClasses::GDistanceMetric
GDomNodebaseDomNode (GDom *pDoc) const
 
void setRelation (const GRelation *pRelation, bool own)
 Sets the relation to use with this metric. Takes ownership of the relation iff own is true. More...
 

Constructor & Destructor Documentation

GClasses::GLNormDistance::GLNormDistance ( double  norm)
GClasses::GLNormDistance::GLNormDistance ( GDomNode pNode)
virtual GClasses::GLNormDistance::~GLNormDistance ( )
inlinevirtual

Member Function Documentation

virtual void GClasses::GLNormDistance::init ( const GRelation pRelation,
bool  own 
)
virtual

See the comment for GDistanceMetric::init.

Implements GClasses::GDistanceMetric.

virtual const char* GClasses::GLNormDistance::name ( ) const
inlinevirtual

Returns the name of this class.

Implements GClasses::GDistanceMetric.

virtual GDomNode* GClasses::GLNormDistance::serialize ( GDom pDoc) const
virtual

See the comment for GDistanceMetric::serialize.

Implements GClasses::GDistanceMetric.

void GClasses::GLNormDistance::setDiffWithUnknown ( double  d)
inline

Specify the difference to use when one or more of the values is unknown. (If your data contains unknown values, you may want to normalize the known values to fall within some pre-determined range, so that it will be possible to select a reasonable value for this purpose.)

virtual double GClasses::GLNormDistance::squaredDistance ( const GVec a,
const GVec b 
) const
virtual

Returns the distance (using the norm passed to the constructor) between pA and pB.

Implements GClasses::GDistanceMetric.

Member Data Documentation

double GClasses::GLNormDistance::m_diffWithUnknown
protected
double GClasses::GLNormDistance::m_norm
protected