public class LinearNNSearch extends NearestNeighbourSearch
-S Skip identical instances (distances equal to zero).
Constructor and Description |
---|
LinearNNSearch()
Constructor.
|
LinearNNSearch(Instances insts)
Constructor that uses the supplied set of
instances.
|
Modifier and Type | Method and Description |
---|---|
void |
addInstanceInfo(Instance ins)
Adds the given instance info.
|
double[] |
getDistances()
Returns the distances of the k nearest neighbours.
|
java.lang.String[] |
getOptions()
Gets the current settings.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
getSkipIdentical()
Gets whether if identical instances are skipped from the neighbourhood.
|
java.lang.String |
globalInfo()
Returns a string describing this nearest neighbour search algorithm.
|
Instances |
kNearestNeighbours(Instance target,
int kNN)
Returns k nearest instances in the current neighbourhood to the supplied
instance.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
Instance |
nearestNeighbour(Instance target)
Returns the nearest instance in the current neighbourhood to the supplied
instance.
|
void |
setInstances(Instances insts)
Sets the instances comprising the current neighbourhood.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setSkipIdentical(boolean skip)
Sets the property to skip identical instances (with distance zero from
the target) from the set of neighbours returned.
|
java.lang.String |
skipIdenticalTipText()
Returns the tip text for this property.
|
void |
update(Instance ins)
Updates the LinearNNSearch to cater for the new added instance.
|
combSort11, distanceFunctionTipText, enumerateMeasures, getDistanceFunction, getInstances, getMeasure, getMeasurePerformance, getPerformanceStats, measurePerformanceTipText, quickSort, setDistanceFunction, setMeasurePerformance
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
makeCopy
public LinearNNSearch()
public LinearNNSearch(Instances insts)
insts
- the instances to usepublic java.lang.String globalInfo()
globalInfo
in class NearestNeighbourSearch
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class NearestNeighbourSearch
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-S Skip identical instances (distances equal to zero).
setOptions
in interface OptionHandler
setOptions
in class NearestNeighbourSearch
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class NearestNeighbourSearch
public java.lang.String skipIdenticalTipText()
public void setSkipIdentical(boolean skip)
skip
- if true, identical intances are skippedpublic boolean getSkipIdentical()
public Instance nearestNeighbour(Instance target) throws java.lang.Exception
nearestNeighbour
in class NearestNeighbourSearch
target
- The instance to find the nearest neighbour for.java.lang.Exception
- if the nearest neighbour could not be found.public Instances kNearestNeighbours(Instance target, int kNN) throws java.lang.Exception
kNearestNeighbours
in class NearestNeighbourSearch
target
- The instance to find the k nearest neighbours for.kNN
- The number of nearest neighbours to find.java.lang.Exception
- if the neighbours could not be found.public double[] getDistances() throws java.lang.Exception
getDistances
in class NearestNeighbourSearch
java.lang.Exception
- if called before calling kNearestNeighbours
or nearestNeighbours.public void setInstances(Instances insts) throws java.lang.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.java.lang.Exception
- if setting of instances failspublic void update(Instance ins) throws java.lang.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.java.lang.Exception
- if the given instances are nullpublic void addInstanceInfo(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.public java.lang.String getRevision()