public class LinearNNSearch extends NearestNeighbourSearch
-S Skip identical instances (distances equal to zero).
NearestNeighbourSearch.MyHeap, NearestNeighbourSearch.MyHeapElement, NearestNeighbourSearch.NeighborList, NearestNeighbourSearch.NeighborNode
Modifier and Type | Field and Description |
---|---|
protected double[] |
m_Distances
Array holding the distances of the nearest neighbours.
|
protected boolean |
m_SkipIdentical
Whether to skip instances from the neighbours that are identical to the query instance.
|
m_DistanceFunction, m_Instances, m_kNN, m_MeasurePerformance
Constructor and Description |
---|
LinearNNSearch()
Constructor.
|
LinearNNSearch(weka.core.Instances insts)
Constructor that uses the supplied set of
instances.
|
Modifier and Type | Method and Description |
---|---|
void |
addInstanceInfo(weka.core.Instance ins)
Adds the given instance info.
|
double[] |
getDistances()
Returns the distances of the k nearest neighbours.
|
boolean |
getSkipIdentical()
Gets whether if identical instances are skipped from the neighbourhood.
|
String |
globalInfo()
Returns a string describing this nearest neighbour search algorithm.
|
weka.core.Instances |
kNearestNeighbours(weka.core.Instance target,
int kNN)
Returns k nearest instances in the current neighbourhood to the supplied
instance.
|
weka.core.Instance |
nearestNeighbour(weka.core.Instance target)
Returns the nearest instance in the current neighbourhood to the supplied
instance.
|
void |
setInstances(weka.core.Instances insts)
Sets the instances comprising the current neighbourhood.
|
void |
setSkipIdentical(boolean skip)
Sets the property to skip identical instances (with distance zero from
the target) from the set of neighbours returned.
|
String |
skipIdenticalTipText()
Returns the tip text for this property.
|
void |
update(weka.core.Instance ins)
Updates the LinearNNSearch to cater for the new added instance.
|
combSort11, distanceFunctionTipText, getDistanceFunction, getInstances, getMeasurePerformance, measurePerformanceTipText, partition, quickSort, setDistanceFunction
protected double[] m_Distances
protected boolean m_SkipIdentical
public LinearNNSearch()
public LinearNNSearch(weka.core.Instances insts)
insts
- the instances to usepublic String globalInfo()
globalInfo
in class NearestNeighbourSearch
public String skipIdenticalTipText()
public void setSkipIdentical(boolean skip)
skip
- if true, identical intances are skippedpublic boolean getSkipIdentical()
public weka.core.Instance nearestNeighbour(weka.core.Instance target) throws Exception
nearestNeighbour
in class NearestNeighbourSearch
target
- The instance to find the nearest neighbour for.Exception
- if the nearest neighbour could not be found.public weka.core.Instances kNearestNeighbours(weka.core.Instance target, int kNN) throws Exception
kNearestNeighbours
in class NearestNeighbourSearch
target
- The instance to find the k nearest neighbours for.kNN
- The number of nearest neighbours to find.Exception
- if the neighbours could not be found.public double[] getDistances() throws Exception
getDistances
in class NearestNeighbourSearch
Exception
- if called before calling kNearestNeighbours
or nearestNeighbours.public void setInstances(weka.core.Instances insts) throws Exception
setInstances
in class NearestNeighbourSearch
insts
- The set of instances on which the nearest neighbour
search is carried out. Usually this set is the
training set.Exception
- if setting of instances failspublic void update(weka.core.Instance ins) throws Exception
update
in class NearestNeighbourSearch
ins
- The instance to add. Usually this is the instance that
is added to our neighbourhood i.e. the training
instances.Exception
- if the given instances are nullpublic void addInstanceInfo(weka.core.Instance ins)
addInstanceInfo
in class NearestNeighbourSearch
ins
- The instance to add the information of. Usually this is
the test instance supplied to update the range of
attributes in the distance function.Copyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.