GClasses
|
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>
Public Member Functions | |
GRowDistance () | |
GRowDistance (GDomNode *pNode) | |
virtual | ~GRowDistance () |
virtual GDomNode * | serialize (GDom *pDoc) |
See the comment for GDistanceMetric::serialize. | |
virtual void | init (sp_relation &pRelation) |
See the comment for GDistanceMetric::init. | |
virtual double | squaredDistance (const double *pA, const double *pB) const |
Returns the distance between pA and pB. | |
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.) | |
Protected Attributes | |
double | m_diffWithUnknown |
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.
GClasses::GRowDistance::GRowDistance | ( | ) |
GClasses::GRowDistance::GRowDistance | ( | GDomNode * | pNode | ) |
virtual GClasses::GRowDistance::~GRowDistance | ( | ) | [inline, virtual] |
virtual void GClasses::GRowDistance::init | ( | sp_relation & | pRelation | ) | [virtual] |
See the comment for GDistanceMetric::init.
Implements GClasses::GDistanceMetric.
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.
double GClasses::GRowDistance::m_diffWithUnknown [protected] |