GClasses
GClasses::GRowDistance Class Reference

This uses a combination of Euclidean distance for continuous attributes, and Hamming distance for nominal attributes. In particular, for each attribute, it calculates pA[i]-pB[i], squares it and takes the square root of that sum. For nominal attributes pA[i]-pB[i] is 0 if they are the same and 1 if they are different. More...

#include <GDistance.h>

Inheritance diagram for GClasses::GRowDistance:
GClasses::GDistanceMetric

Public Member Functions

 GRowDistance ()
 
 GRowDistance (GDomNode *pNode)
 
virtual ~GRowDistance ()
 
virtual void init (const GRelation *pRelation, bool own)
 See the comment for GDistanceMetric::init. 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 double *pA, const double *pB) const
 Returns the distance between pA and pB. More...
 
- Public Member Functions inherited from GClasses::GDistanceMetric
 GDistanceMetric ()
 
 GDistanceMetric (GDomNode *pNode)
 
virtual ~GDistanceMetric ()
 
double operator() (const std::vector< double > &a, const std::vector< double > &b) const
 Return squaredDistance(a,b). Allows dissimilarity metrics to be used as function objects. Do not override. Override squaredDistance(a,b) instead. See GDistanceMetric::squaredDistance(const std::vector<double>&, const std::vector<double>&) More...
 
double operator() (const double *pA, const double *pB) 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 double*, const double*) More...
 
const GRelationrelation () const
 Returns the relation that specifies the meaning of the vector elements. More...
 
virtual double * scaleFactors ()
 Returns a pointer to the vector of scale factors. This may be NULL if the metric does not use scale factors. More...
 
virtual double squaredDistance (const std::vector< double > &a, const std::vector< double > &b) const
 Return the squared distance (or squared dissimilarity) between the two specified vectors. More...
 

Protected Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from GClasses::GDistanceMetric
static GDistanceMetricdeserialize (GDomNode *pNode)
 Deserializes a distance metric. More...
 
- Protected Member Functions inherited from GClasses::GDistanceMetric
GDomNodebaseDomNode (GDom *pDoc, const char *szClassName) 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...
 

Detailed Description

This uses a combination of Euclidean distance for continuous attributes, and Hamming distance for nominal attributes. In particular, for each attribute, it calculates pA[i]-pB[i], squares it and takes the square root of that sum. For nominal attributes pA[i]-pB[i] is 0 if they are the same and 1 if they are different.

Constructor & Destructor Documentation

GClasses::GRowDistance::GRowDistance ( )
GClasses::GRowDistance::GRowDistance ( GDomNode pNode)
virtual GClasses::GRowDistance::~GRowDistance ( )
inlinevirtual

Member Function Documentation

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

See the comment for GDistanceMetric::init.

Implements GClasses::GDistanceMetric.

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

See the comment for GDistanceMetric::serialize.

Implements GClasses::GDistanceMetric.

void GClasses::GRowDistance::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::GRowDistance::squaredDistance ( const double *  pA,
const double *  pB 
) const
virtual

Returns the distance between pA and pB.

Implements GClasses::GDistanceMetric.

Member Data Documentation

double GClasses::GRowDistance::m_diffWithUnknown
protected