程序包 weka.core
类 NormalizableDistance
java.lang.Object
weka.core.NormalizableDistance
- 所有已实现的接口:
Serializable
,DistanceFunction
,OptionHandler
,RevisionHandler
public abstract class NormalizableDistance
extends Object
implements DistanceFunction, OptionHandler, Serializable, RevisionHandler
Represents the abstract ancestor for normalizable distance functions, like
Euclidean or Manhattan distance.
- 版本:
- $Revision: 1.2 $
- 作者:
- Fracpete (fracpete at waikato dot ac dot nz), Gabi Schmidberger (gabi@cs.waikato.ac.nz) -- original code from weka.core.EuclideanDistance, Ashraf M. Kibriya (amk14@cs.waikato.ac.nz) -- original code from weka.core.EuclideanDistance
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器构造器说明Invalidates the distance function, Instances must be still set.Initializes the distance function and automatically initializes the ranges. -
方法概要
修饰符和类型方法说明Returns the tip text for this property.void
clean()
Free any references to training instancesdouble
Calculates the distance between two instances.double
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.Returns the tip text for this property.Gets the range of attributes used in the calculation of the distance.boolean
Gets whether if the attribute values are to be normazlied in distance calculation.returns the instances currently set.boolean
Gets whether the matching sense of attribute indices is inverted or not.String[]
Gets the current settings.double[][]
Method to get the ranges.abstract String
Returns a string describing this object.double[][]
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
Test if an instance is within the given ranges.Returns the tip text for this property.Returns an enumeration describing the available options.void
postProcessDistances
(double[] distances) Does nothing, derived classes may override it though.boolean
Check if ranges are set.void
setAttributeIndices
(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
(String[] options) Parses a given list of options.toString()
Returns an empty string.void
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.从接口继承的方法 weka.core.RevisionHandler
getRevision
-
字段详细资料
-
构造器详细资料
-
NormalizableDistance
public NormalizableDistance()Invalidates the distance function, Instances must be still set. -
NormalizableDistance
Initializes the distance function and automatically initializes the ranges.- 参数:
data
- the instances the distance function should work on
-
-
方法详细资料
-
globalInfo
Returns a string describing this object.- 返回:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
listOptions
Returns an enumeration describing the available options.- 指定者:
listOptions
在接口中OptionHandler
- 返回:
- an enumeration of all the available options.
-
getOptions
Gets the current settings. Returns empty array.- 指定者:
getOptions
在接口中OptionHandler
- 返回:
- an array of strings suitable for passing to setOptions()
-
setOptions
Parses a given list of options.- 指定者:
setOptions
在接口中OptionHandler
- 参数:
options
- the list of options as an array of strings- 抛出:
Exception
- if an option is not supported
-
dontNormalizeTipText
Returns the tip text for this property.- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setDontNormalize
public void setDontNormalize(boolean dontNormalize) Sets whether if the attribute values are to be normalized in distance calculation.- 参数:
dontNormalize
- if true the values are not normalized
-
getDontNormalize
public boolean getDontNormalize()Gets whether if the attribute values are to be normazlied in distance calculation. (default false i.e. attribute values are normalized.)- 返回:
- false if values get normalized
-
attributeIndicesTipText
Returns the tip text for this property.- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setAttributeIndices
Sets the range of attributes to use in the calculation of the distance. The indices start from 1, 'first' and 'last' are valid as well. E.g.: first-3,5,6-last- 指定者:
setAttributeIndices
在接口中DistanceFunction
- 参数:
value
- the new attribute index range
-
getAttributeIndices
Gets the range of attributes used in the calculation of the distance.- 指定者:
getAttributeIndices
在接口中DistanceFunction
- 返回:
- the attribute index range
-
invertSelectionTipText
Returns the tip text for this property.- 返回:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setInvertSelection
public void setInvertSelection(boolean value) Sets whether the matching sense of attribute indices is inverted or not.- 指定者:
setInvertSelection
在接口中DistanceFunction
- 参数:
value
- if true the matching sense is inverted
-
getInvertSelection
public boolean getInvertSelection()Gets whether the matching sense of attribute indices is inverted or not.- 指定者:
getInvertSelection
在接口中DistanceFunction
- 返回:
- true if the matching sense is inverted
-
setInstances
Sets the instances.- 指定者:
setInstances
在接口中DistanceFunction
- 参数:
insts
- the instances to use
-
getInstances
returns the instances currently set.- 指定者:
getInstances
在接口中DistanceFunction
- 返回:
- the current instances
-
postProcessDistances
public void postProcessDistances(double[] distances) Does nothing, derived classes may override it though.- 指定者:
postProcessDistances
在接口中DistanceFunction
- 参数:
distances
- the distances to post-process
-
update
Update the distance function (if necessary) for the newly added instance.- 指定者:
update
在接口中DistanceFunction
- 参数:
ins
- the instance to add
-
distance
Calculates the distance between two instances.- 指定者:
distance
在接口中DistanceFunction
- 参数:
first
- the first instancesecond
- the second instance- 返回:
- the distance between the two given instances
-
distance
Calculates the distance between two instances.- 指定者:
distance
在接口中DistanceFunction
- 参数:
first
- the first instancesecond
- the second instancestats
- the performance stats object- 返回:
- the distance between the two given instances
-
distance
Calculates the distance between two instances. Offers speed up (if the distance function class in use supports it) in nearest neighbour search by taking into account the cutOff or maximum distance. Depending on the distance function class, post processing of the distances by postProcessDistances(double []) may be required if this function is used.- 指定者:
distance
在接口中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.- 返回:
- the distance between the two given instances or Double.POSITIVE_INFINITY if the distance being calculated becomes larger than cutOffValue.
-
distance
Calculates the distance between two instances. Offers speed up (if the distance function class in use supports it) in nearest neighbour search by taking into account the cutOff or maximum distance. Depending on the distance function class, post processing of the distances by postProcessDistances(double []) may be required if this function is used.- 指定者:
distance
在接口中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- 返回:
- the distance between the two given instances or Double.POSITIVE_INFINITY if the distance being calculated becomes larger than cutOffValue.
-
initializeRanges
public double[][] initializeRanges()Initializes the ranges using all instances of the dataset. Sets m_Ranges.- 返回:
- the ranges
-
updateRangesFirst
Used to initialize the ranges. For this the values of the first instance is used to save time. Sets low and high to the values of the first instance and width to zero.- 参数:
instance
- the new instancenumAtt
- number of attributes in the modelranges
- low, high and width values for all attributes
-
updateRanges
Updates the minimum and maximum and width values for all the attributes based on a new instance.- 参数:
instance
- the new instancenumAtt
- number of attributes in the modelranges
- low, high and width values for all attributes
-
initializeRangesEmpty
public void initializeRangesEmpty(int numAtt, double[][] ranges) Used to initialize the ranges.- 参数:
numAtt
- number of attributes in the modelranges
- low, high and width values for all attributes
-
updateRanges
Updates the ranges given a new instance.- 参数:
instance
- the new instanceranges
- low, high and width values for all attributes- 返回:
- the updated ranges
-
initializeRanges
Initializes the ranges of a subset of the instances of this dataset. Therefore m_Ranges is not set.- 参数:
instList
- list of indexes of the subset- 返回:
- the ranges
- 抛出:
Exception
- if something goes wrong
-
initializeRanges
Initializes the ranges of a subset of the instances of this dataset. Therefore m_Ranges is not set. The caller of this method should ensure that the supplied start and end indices are valid (start <= end, end<instList.length etc) and correct.- 参数:
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- 返回:
- the ranges
- 抛出:
Exception
- if something goes wrong
-
updateRanges
Update the ranges if a new instance comes.- 参数:
instance
- the new instance
-
inRanges
Test if an instance is within the given ranges.- 参数:
instance
- the instanceranges
- the ranges the instance is tested to be in- 返回:
- true if instance is within the ranges
-
clean
public void clean()Free any references to training instances- 指定者:
clean
在接口中DistanceFunction
-
rangesSet
public boolean rangesSet()Check if ranges are set.- 返回:
- true if ranges are set
-
getRanges
Method to get the ranges.- 返回:
- the ranges
- 抛出:
Exception
- if no randes are set yet
-
toString
Returns an empty string.
-