|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.NormalizableDistance
public abstract class NormalizableDistance
Represents the abstract ancestor for normalizable distance functions, like Euclidean or Manhattan distance.
Field Summary | |
---|---|
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 Summary | |
---|---|
NormalizableDistance()
Invalidates the distance function, Instances must be still set. |
|
NormalizableDistance(Instances data)
Initializes the distance function and automatically initializes the ranges. |
Method Summary | |
---|---|
java.lang.String |
attributeIndicesTipText()
Returns the tip text for this property. |
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 |
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface weka.core.RevisionHandler |
---|
getRevision |
Field Detail |
---|
public static final int R_MIN
public static final int R_MAX
public static final int R_WIDTH
Constructor Detail |
---|
public NormalizableDistance()
public NormalizableDistance(Instances data)
data
- the instances the distance function should work onMethod Detail |
---|
public abstract java.lang.String globalInfo()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
public void setOptions(java.lang.String[] options) throws java.lang.Exception
setOptions
in interface OptionHandler
options
- the list of options as an array of strings
java.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 DistanceFunction
value
- the new attribute index rangepublic java.lang.String getAttributeIndices()
getAttributeIndices
in interface DistanceFunction
public java.lang.String invertSelectionTipText()
public void setInvertSelection(boolean value)
setInvertSelection
in interface DistanceFunction
value
- if true the matching sense is invertedpublic boolean getInvertSelection()
getInvertSelection
in interface DistanceFunction
public void setInstances(Instances insts)
setInstances
in interface DistanceFunction
insts
- the instances to usepublic Instances getInstances()
getInstances
in interface DistanceFunction
public void postProcessDistances(double[] distances)
postProcessDistances
in interface DistanceFunction
distances
- the distances to post-processpublic void update(Instance ins)
update
in interface DistanceFunction
ins
- the instance to addpublic double distance(Instance first, Instance second)
distance
in interface DistanceFunction
first
- the first instancesecond
- the second instance
public double distance(Instance first, Instance second, PerformanceStats stats)
distance
in interface DistanceFunction
first
- the first instancesecond
- the second instancestats
- the performance stats object
public double distance(Instance first, Instance second, double cutOffValue)
distance
in interface DistanceFunction
first
- 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 DistanceFunction
first
- 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 object
public 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 attributes
public double[][] initializeRanges(int[] instList) throws java.lang.Exception
instList
- list of indexes of the subset
java.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 array
java.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 in
public boolean rangesSet()
public double[][] getRanges() throws java.lang.Exception
java.lang.Exception
- if no randes are set yetpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |