public abstract class NormalizableDistance extends java.lang.Object implements DistanceFunction, OptionHandler, java.io.Serializable, RevisionHandler
| Modifier and Type | Field and Description |
|---|---|
static int |
R_MAX
Index in ranges for MAX.
|
static int |
R_MIN
Index in ranges for MIN.
|
static int |
R_WIDTH
Index in ranges for WIDTH.
|
| Constructor and Description |
|---|
NormalizableDistance()
Invalidates the distance function, Instances must be still set.
|
NormalizableDistance(Instances data)
Initializes the distance function and automatically initializes the ranges.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
attributeIndicesTipText()
Returns the tip text for this property.
|
void |
clean()
Free any references to training instances
|
double |
distance(Instance first,
Instance second)
Calculates the distance between two instances.
|
double |
distance(Instance first,
Instance second,
double cutOffValue)
Calculates the distance between two instances.
|
double |
distance(Instance first,
Instance second,
double cutOffValue,
PerformanceStats stats)
Calculates the distance between two instances.
|
double |
distance(Instance first,
Instance second,
PerformanceStats stats)
Calculates the distance between two instances.
|
java.lang.String |
dontNormalizeTipText()
Returns the tip text for this property.
|
java.lang.String |
getAttributeIndices()
Gets the range of attributes used in the calculation of the distance.
|
boolean |
getDontNormalize()
Gets whether if the attribute values are to be normazlied in distance
calculation.
|
Instances |
getInstances()
returns the instances currently set.
|
boolean |
getInvertSelection()
Gets whether the matching sense of attribute indices is inverted or not.
|
java.lang.String[] |
getOptions()
Gets the current settings.
|
double[][] |
getRanges()
Method to get the ranges.
|
abstract java.lang.String |
globalInfo()
Returns a string describing this object.
|
double[][] |
initializeRanges()
Initializes the ranges using all instances of the dataset.
|
double[][] |
initializeRanges(int[] instList)
Initializes the ranges of a subset of the instances of this dataset.
|
double[][] |
initializeRanges(int[] instList,
int startIdx,
int endIdx)
Initializes the ranges of a subset of the instances of this dataset.
|
void |
initializeRangesEmpty(int numAtt,
double[][] ranges)
Used to initialize the ranges.
|
boolean |
inRanges(Instance instance,
double[][] ranges)
Test if an instance is within the given ranges.
|
java.lang.String |
invertSelectionTipText()
Returns the tip text for this property.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
void |
postProcessDistances(double[] distances)
Does nothing, derived classes may override it though.
|
boolean |
rangesSet()
Check if ranges are set.
|
void |
setAttributeIndices(java.lang.String value)
Sets the range of attributes to use in the calculation of the distance.
|
void |
setDontNormalize(boolean dontNormalize)
Sets whether if the attribute values are to be normalized in distance
calculation.
|
void |
setInstances(Instances insts)
Sets the instances.
|
void |
setInvertSelection(boolean value)
Sets whether the matching sense of attribute indices is inverted or not.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
java.lang.String |
toString()
Returns an empty string.
|
void |
update(Instance ins)
Update the distance function (if necessary) for the newly added instance.
|
void |
updateRanges(Instance instance)
Update the ranges if a new instance comes.
|
double[][] |
updateRanges(Instance instance,
double[][] ranges)
Updates the ranges given a new instance.
|
void |
updateRanges(Instance instance,
int numAtt,
double[][] ranges)
Updates the minimum and maximum and width values for all the attributes
based on a new instance.
|
void |
updateRangesFirst(Instance instance,
int numAtt,
double[][] ranges)
Used to initialize the ranges.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRevisionpublic static final int R_MIN
public static final int R_MAX
public static final int R_WIDTH
public NormalizableDistance()
public NormalizableDistance(Instances data)
data - the instances the distance function should work onpublic abstract java.lang.String globalInfo()
public java.util.Enumeration<Option> listOptions()
listOptions in interface OptionHandlerpublic java.lang.String[] getOptions()
getOptions in interface OptionHandlerpublic void setOptions(java.lang.String[] options)
throws java.lang.Exception
setOptions in interface OptionHandleroptions - the list of options as an array of stringsjava.lang.Exception - if an option is not supportedpublic java.lang.String dontNormalizeTipText()
public void setDontNormalize(boolean dontNormalize)
dontNormalize - if true the values are not normalizedpublic boolean getDontNormalize()
public java.lang.String attributeIndicesTipText()
public void setAttributeIndices(java.lang.String value)
setAttributeIndices in interface DistanceFunctionvalue - the new attribute index rangepublic java.lang.String getAttributeIndices()
getAttributeIndices in interface DistanceFunctionpublic java.lang.String invertSelectionTipText()
public void setInvertSelection(boolean value)
setInvertSelection in interface DistanceFunctionvalue - if true the matching sense is invertedpublic boolean getInvertSelection()
getInvertSelection in interface DistanceFunctionpublic void setInstances(Instances insts)
setInstances in interface DistanceFunctioninsts - the instances to usepublic Instances getInstances()
getInstances in interface DistanceFunctionpublic void postProcessDistances(double[] distances)
postProcessDistances in interface DistanceFunctiondistances - the distances to post-processpublic void update(Instance ins)
update in interface DistanceFunctionins - the instance to addpublic double distance(Instance first, Instance second)
distance in interface DistanceFunctionfirst - the first instancesecond - the second instancepublic double distance(Instance first, Instance second, PerformanceStats stats)
distance in interface DistanceFunctionfirst - the first instancesecond - the second instancestats - the performance stats objectpublic double distance(Instance first, Instance second, double cutOffValue)
distance in interface DistanceFunctionfirst - the first instancesecond - the second instancecutOffValue - If the distance being calculated becomes larger than
cutOffValue then the rest of the calculation is discarded.public double distance(Instance first, Instance second, double cutOffValue, PerformanceStats stats)
distance in interface DistanceFunctionfirst - the first instancesecond - the second instancecutOffValue - If the distance being calculated becomes larger than
cutOffValue then the rest of the calculation is discarded.stats - the performance stats objectpublic double[][] initializeRanges()
public void updateRangesFirst(Instance instance, int numAtt, double[][] ranges)
instance - the new instancenumAtt - number of attributes in the modelranges - low, high and width values for all attributespublic void updateRanges(Instance instance, int numAtt, double[][] ranges)
instance - the new instancenumAtt - number of attributes in the modelranges - low, high and width values for all attributespublic void initializeRangesEmpty(int numAtt,
double[][] ranges)
numAtt - number of attributes in the modelranges - low, high and width values for all attributespublic double[][] updateRanges(Instance instance, double[][] ranges)
instance - the new instanceranges - low, high and width values for all attributespublic double[][] initializeRanges(int[] instList)
throws java.lang.Exception
instList - list of indexes of the subsetjava.lang.Exception - if something goes wrongpublic double[][] initializeRanges(int[] instList,
int startIdx,
int endIdx)
throws java.lang.Exception
instList - list of indexes of the instancesstartIdx - start index of the subset of instances in the indices arrayendIdx - end index of the subset of instances in the indices arrayjava.lang.Exception - if something goes wrongpublic void updateRanges(Instance instance)
instance - the new instancepublic boolean inRanges(Instance instance, double[][] ranges)
instance - the instanceranges - the ranges the instance is tested to be inpublic boolean rangesSet()
public double[][] getRanges()
throws java.lang.Exception
java.lang.Exception - if no randes are set yetpublic void clean()
DistanceFunctionclean in interface DistanceFunctionpublic java.lang.String toString()
toString in class java.lang.Object