public abstract class NearestNeighbourSearch extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
NearestNeighbourSearch.MyHeap
A class for a heap to store the nearest k neighbours to an instance.
|
protected class |
NearestNeighbourSearch.MyHeapElement
A class for storing data about a neighboring instance.
|
protected class |
NearestNeighbourSearch.NeighborList
A class for a linked list to store the nearest k neighbours
to an instance.
|
protected class |
NearestNeighbourSearch.NeighborNode
A class for storing data about a neighboring instance.
|
Modifier and Type | Field and Description |
---|---|
protected DistanceFunction |
m_DistanceFunction
the distance function used.
|
protected weka.core.Instances |
m_Instances
The neighbourhood of instances to find neighbours in.
|
protected int |
m_kNN
The number of neighbours to find.
|
protected boolean |
m_MeasurePerformance
Should we measure Performance.
|
Constructor and Description |
---|
NearestNeighbourSearch()
Constructor.
|
NearestNeighbourSearch(weka.core.Instances insts)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addInstanceInfo(weka.core.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.
|
String |
distanceFunctionTipText()
Returns the tip text for this property.
|
DistanceFunction |
getDistanceFunction()
returns the distance function currently in use.
|
abstract double[] |
getDistances()
Returns the distances of the k nearest neighbours.
|
weka.core.Instances |
getInstances()
returns the instances currently set.
|
boolean |
getMeasurePerformance()
Gets whether performance statistics are being calculated or not.
|
String |
globalInfo()
Returns a string describing this nearest neighbour search algorithm.
|
abstract weka.core.Instances |
kNearestNeighbours(weka.core.Instance target,
int k)
Returns k nearest instances in the current neighbourhood to the supplied
instance.
|
String |
measurePerformanceTipText()
Returns the tip text for this property.
|
abstract weka.core.Instance |
nearestNeighbour(weka.core.Instance target)
Returns the nearest instance in the current neighbourhood to the supplied
instance.
|
protected static int |
partition(double[] arrayToSort,
double[] linkedArray,
int l,
int r)
Partitions the instances around a pivot.
|
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(weka.core.Instances insts)
Sets the instances.
|
abstract void |
update(weka.core.Instance ins)
Updates the NearNeighbourSearch algorithm for the new added instance.
|
protected weka.core.Instances m_Instances
protected int m_kNN
protected DistanceFunction m_DistanceFunction
protected boolean m_MeasurePerformance
public NearestNeighbourSearch()
public NearestNeighbourSearch(weka.core.Instances insts)
insts
- The set of instances that constitute the neighbourhood.public String globalInfo()
public String distanceFunctionTipText()
public DistanceFunction getDistanceFunction()
public void setDistanceFunction(DistanceFunction df) throws Exception
df
- the new distance function to useException
- if instances cannot be processedpublic String measurePerformanceTipText()
public boolean getMeasurePerformance()
public abstract weka.core.Instance nearestNeighbour(weka.core.Instance target) throws Exception
target
- The instance to find the nearest neighbour for.Exception
- if the nearest neighbour could not be found.public abstract weka.core.Instances kNearestNeighbours(weka.core.Instance target, int k) throws Exception
target
- The instance to find the k nearest neighbours for.k
- The number of nearest neighbours to find.Exception
- if the neighbours could not be found.public abstract double[] getDistances() throws Exception
Exception
- if called before calling kNearestNeighbours
or nearestNeighbours.public abstract void update(weka.core.Instance ins) throws Exception
ins
- the instance to addException
- if updating failspublic void addInstanceInfo(weka.core.Instance ins)
ins
- the instance to add the information frompublic void setInstances(weka.core.Instances insts) throws Exception
insts
- the instances to useException
- if setting failspublic weka.core.Instances getInstances()
public 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.protected static int partition(double[] arrayToSort, double[] linkedArray, int l, int r)
arrayToSort
- the array of doubles to be sortedlinkedArray
- the linked arrayl
- the first index of the subsetr
- the last index of the subsetpublic 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 subsetCopyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.