public abstract class NearestNeighbourSearch extends java.lang.Object implements java.io.Serializable, OptionHandler, AdditionalMeasureProducer, RevisionHandler
| Constructor and Description |
|---|
NearestNeighbourSearch()
Constructor.
|
NearestNeighbourSearch(Instances insts)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInstanceInfo(Instance ins)
Adds information from the given instance without modifying the
datastructure a lot.
|
static void |
combSort11(double[] arrayToSort,
int[] linkedArray)
sorts the two given arrays.
|
java.lang.String |
distanceFunctionTipText()
Returns the tip text for this property.
|
java.util.Enumeration<java.lang.String> |
enumerateMeasures()
Returns an enumeration of the additional measure names.
|
DistanceFunction |
getDistanceFunction()
returns the distance function currently in use.
|
abstract double[] |
getDistances()
Returns the distances of the k nearest neighbours.
|
Instances |
getInstances()
returns the instances currently set.
|
double |
getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure.
|
boolean |
getMeasurePerformance()
Gets whether performance statistics are being calculated or not.
|
java.lang.String[] |
getOptions()
Gets the current settings.
|
PerformanceStats |
getPerformanceStats()
Gets the class object that contains the performance statistics of the
search method.
|
java.lang.String |
globalInfo()
Returns a string describing this nearest neighbour search algorithm.
|
abstract Instances |
kNearestNeighbours(Instance target,
int k)
Returns k nearest instances in the current neighbourhood to the supplied
instance.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
java.lang.String |
measurePerformanceTipText()
Returns the tip text for this property.
|
abstract Instance |
nearestNeighbour(Instance target)
Returns the nearest instance in the current neighbourhood to the supplied
instance.
|
static void |
quickSort(double[] arrayToSort,
double[] linkedArray,
int left,
int right)
performs quicksort.
|
void |
setDistanceFunction(DistanceFunction df)
sets the distance function to use for nearest neighbour search.
|
void |
setInstances(Instances insts)
Sets the instances.
|
void |
setMeasurePerformance(boolean measurePerformance)
Sets whether to calculate the performance statistics or not.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
abstract void |
update(Instance ins)
Updates the NearNeighbourSearch algorithm for the new added instance.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmakeCopygetRevisionpublic NearestNeighbourSearch()
public NearestNeighbourSearch(Instances insts)
insts - The set of instances that constitute the neighbourhood.public java.lang.String globalInfo()
public java.util.Enumeration<Option> listOptions()
listOptions 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[] getOptions()
getOptions in interface OptionHandlerpublic java.lang.String distanceFunctionTipText()
public DistanceFunction getDistanceFunction()
public void setDistanceFunction(DistanceFunction df) throws java.lang.Exception
df - the new distance function to usejava.lang.Exception - if instances cannot be processedpublic java.lang.String measurePerformanceTipText()
public boolean getMeasurePerformance()
public void setMeasurePerformance(boolean measurePerformance)
measurePerformance - if true then the performance is calculatedpublic abstract Instance nearestNeighbour(Instance target) throws java.lang.Exception
target - The instance to find the nearest neighbour for.java.lang.Exception - if the nearest neighbour could not be found.public abstract Instances kNearestNeighbours(Instance target, int k) throws java.lang.Exception
target - The instance to find the k nearest neighbours for.k - The number of nearest neighbours to find.java.lang.Exception - if the neighbours could not be found.public abstract double[] getDistances()
throws java.lang.Exception
java.lang.Exception - if called before calling kNearestNeighbours or
nearestNeighbours.public abstract void update(Instance ins) throws java.lang.Exception
ins - the instance to addjava.lang.Exception - if updating failspublic void addInstanceInfo(Instance ins)
ins - the instance to add the information frompublic void setInstances(Instances insts) throws java.lang.Exception
insts - the instances to usejava.lang.Exception - if setting failspublic Instances getInstances()
public PerformanceStats getPerformanceStats()
public java.util.Enumeration<java.lang.String> enumerateMeasures()
enumerateMeasures in interface AdditionalMeasureProducerpublic double getMeasure(java.lang.String additionalMeasureName)
getMeasure in interface AdditionalMeasureProduceradditionalMeasureName - the name of the measure to query for its valuejava.lang.IllegalArgumentException - if the named measure is not supportedpublic static void combSort11(double[] arrayToSort,
int[] linkedArray)
arrayToSort - The array sorting should be based on.linkedArray - The array that should have the same ordering as
arrayToSort.public static void quickSort(double[] arrayToSort,
double[] linkedArray,
int left,
int right)
arrayToSort - the array to sortlinkedArray - the linked arrayleft - the first index of the subsetright - the last index of the subset