public class FilteredDistance extends java.lang.Object implements DistanceFunction, OptionHandler, java.io.Serializable
-F The filter to use. (default: weka.unsupervised.attribute.RandomProjection
-E The distance function to use. (default: weka.core.EuclideanDistance
Options specific to filter weka.filters.unsupervised.attribute.RandomProjection:
-N <number> The number of dimensions (attributes) the data should be reduced to (default 10; exclusive of the class attribute, if it is set).
-D [SPARSE1|SPARSE2|GAUSSIAN] The distribution to use for calculating the random matrix. Sparse1 is: sqrt(3)*{-1 with prob(1/6), 0 with prob(2/3), +1 with prob(1/6)} Sparse2 is: {-1 with prob(1/2), +1 with prob(1/2)}
-P <percent> The percentage of dimensions (attributes) the data should be reduced to (exclusive of the class attribute, if it is set). The -N option is ignored if this option is present and is greater than zero.
-M Replace missing values using the ReplaceMissingValues filter
-R <num> The random seed for the random number generator used for calculating the random matrix (default 42).
Options specific to distance function weka.core.EuclideanDistance:
-D Turns off the normalization of attribute values in distance calculation.
-R <col1,col2-col4,...> Specifies list of columns to used in the calculation of the distance. 'first' and 'last' are valid indices. (default: first-last)
-V Invert matching sense of column indices.
-R <col1,col2-col4,...> Specifies list of columns to used in the calculation of the distance. 'first' and 'last' are valid indices. (default: first-last)
-V Invert matching sense of column indices.
Constructor and Description |
---|
FilteredDistance()
Default constructor: need to set up Remove filter.
|
Modifier and Type | Method and Description |
---|---|
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 |
distanceTipText()
Returns the tip text for this property
|
java.lang.String |
filterTipText()
Returns the tip text for this property
|
java.lang.String |
getAttributeIndices()
Gets the range of attributes used in the calculation of the distance.
|
DistanceFunction |
getDistance()
Gets the distance used.
|
Filter |
getFilter()
Gets the filter used.
|
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.
|
java.lang.String |
globalInfo()
Returns a string describing this object.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
void |
postProcessDistances(double[] distances)
Does post processing of the distances (if necessary) returned by
distance(distance(Instance first, Instance second, double cutOffValue).
|
void |
setAttributeIndices(java.lang.String value)
Sets the range of attributes to use in the calculation of the distance.
|
void |
setDistance(DistanceFunction distance)
Sets the distance
|
void |
setFilter(Filter filter)
Sets the filter
|
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.
|
void |
update(Instance ins)
Update the distance function (if necessary) for the newly added instance.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeCopy
public FilteredDistance()
public java.lang.String globalInfo()
public java.lang.String filterTipText()
public void setFilter(Filter filter)
filter
- the filter with all options set.public Filter getFilter()
public java.lang.String distanceTipText()
public void setDistance(DistanceFunction distance)
distance
- the distance with all options set.public DistanceFunction getDistance()
public java.util.Enumeration<Option> 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 stringsjava.lang.Exception
- if an option is not supportedpublic void setInstances(Instances insts)
setInstances
in interface DistanceFunction
insts
- the instances to usepublic Instances getInstances()
getInstances
in interface DistanceFunction
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 void setInvertSelection(boolean value)
setInvertSelection
in interface DistanceFunction
value
- if true the matching sense is invertedpublic boolean getInvertSelection()
getInvertSelection
in interface DistanceFunction
public double distance(Instance first, Instance second)
distance
in interface DistanceFunction
first
- the first instancesecond
- the second instancepublic double distance(Instance first, Instance second, PerformanceStats stats) throws java.lang.Exception
distance
in interface DistanceFunction
first
- the first instancesecond
- the second instancestats
- the performance stats objectjava.lang.Exception
- if calculation failspublic 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 objectpublic 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 void clean()
clean
in interface DistanceFunction