Package weka.core.neighboursearch
Class FilteredNeighbourSearch
- java.lang.Object
-
- weka.core.neighboursearch.NearestNeighbourSearch
-
- weka.core.neighboursearch.FilteredNeighbourSearch
-
- All Implemented Interfaces:
java.io.Serializable,AdditionalMeasureProducer,CapabilitiesHandler,OptionHandler,RevisionHandler
public class FilteredNeighbourSearch extends NearestNeighbourSearch implements CapabilitiesHandler
Applies the given filter before calling the given neighbour search method. The filter must not change the size of the dataset or the order of the instances! Also, the range setting that is specified for the distance function is ignored: all attributes are used for the distance calculation. Valid options are:-F The filter to use. (default: weka.filters.AllFilter)
-S The search method to use. (default: weka.core.neighboursearch.LinearNNSearch)
Options specific to filter weka.filters.AllFilter:
-output-debug-info If set, filter is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, filter capabilities are not checked before filter is built (use with caution).
Options specific to search method weka.core.neighboursearch.LinearNNSearch:
-S Skip identical instances (distances equal to zero).
-A <classname and options> Distance function to use. (default: weka.core.EuclideanDistance)
-P Calculate performance statistics.
- Version:
- $Revision: 8034 $
- Author:
- Eibe Frank (eibe@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FilteredNeighbourSearch()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInstanceInfo(Instance ins)Updates the instance info in the underlying search method, once the instance has been filtered.java.lang.StringfilterTipText()Returns the tip text for this propertyCapabilitiesgetCapabilities()Returns default capabilities of the classifier.double[]getDistances()Returns the distances for the nearest neighbours in the FILTERED spaceFiltergetFilter()Gets the filter used.java.lang.String[]getOptions()Gets the current settings.java.lang.StringgetRevision()Returns the revision stringNearestNeighbourSearchgetSearchMethod()Gets the search method used.java.lang.StringglobalInfo()Returns a string describing this object.InstanceskNearestNeighbours(Instance target, int k)Returns the nearest neighbours for the given instance based on distance measured in the filtered space.java.util.Enumeration<Option>listOptions()Returns an enumeration describing the available options.InstancenearestNeighbour(Instance target)Returns the nearest neighbour for the given instance based on distance measured in the filtered space.java.lang.StringsearchMethodTipText()Returns the tip text for this propertyvoidsetFilter(Filter filter)Sets the filtervoidsetInstances(Instances data)Sets the instances to build the filtering model from.voidsetOptions(java.lang.String[] options)Parses a given list of options.voidsetSearchMethod(NearestNeighbourSearch search)Sets the search methodvoidupdate(Instance ins)Updates ranges based on the given instance, once it has been filtered.-
Methods inherited from class weka.core.neighboursearch.NearestNeighbourSearch
combSort11, distanceFunctionTipText, enumerateMeasures, getDistanceFunction, getInstances, getMeasure, getMeasurePerformance, getPerformanceStats, measurePerformanceTipText, quickSort, setDistanceFunction, setMeasurePerformance
-
-
-
-
Method Detail
-
getCapabilities
public Capabilities getCapabilities()
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Returns:
- the capabilities of this classifier
- See Also:
Capabilities
-
setInstances
public void setInstances(Instances data)
Sets the instances to build the filtering model from.- Overrides:
setInstancesin classNearestNeighbourSearch- Parameters:
insts- the Instances object
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this object.- Overrides:
globalInfoin classNearestNeighbourSearch- Returns:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
filterTipText
public java.lang.String filterTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFilter
public void setFilter(Filter filter)
Sets the filter- Parameters:
filter- the filter with all options set.
-
getFilter
public Filter getFilter()
Gets the filter used.- Returns:
- the filter
-
searchMethodTipText
public java.lang.String searchMethodTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSearchMethod
public void setSearchMethod(NearestNeighbourSearch search)
Sets the search method- Parameters:
searchMethod- the search method with all options set.
-
getSearchMethod
public NearestNeighbourSearch getSearchMethod()
Gets the search method used.- Returns:
- the search method
-
listOptions
public java.util.Enumeration<Option> listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classNearestNeighbourSearch- Returns:
- an enumeration of all the available options.
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings. Returns empty array.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classNearestNeighbourSearch- Returns:
- an array of strings suitable for passing to setOptions()
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a given list of options.- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classNearestNeighbourSearch- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getRevision
public java.lang.String getRevision()
Returns the revision string- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
- See Also:
RevisionHandler.getRevision()
-
nearestNeighbour
public Instance nearestNeighbour(Instance target) throws java.lang.Exception
Returns the nearest neighbour for the given instance based on distance measured in the filtered space.- Specified by:
nearestNeighbourin classNearestNeighbourSearch- Parameters:
target- the instance for which to find the nearest neighbour- Returns:
- the nearest neighbour
- Throws:
java.lang.Exception- if the nearest neighbour could not be found.- See Also:
NearestNeighbourSearch.nearestNeighbour(weka.core.Instance)
-
kNearestNeighbours
public Instances kNearestNeighbours(Instance target, int k) throws java.lang.Exception
Returns the nearest neighbours for the given instance based on distance measured in the filtered space.- Specified by:
kNearestNeighboursin classNearestNeighbourSearch- Parameters:
target- the instance for which to find the nearest neighbourk- the number of nearest neighbours to return- Returns:
- the nearest Neighbours
- Throws:
java.lang.Exception- if the neighbours could not be found.- See Also:
NearestNeighbourSearch.kNearestNeighbours(weka.core.Instance, int)
-
getDistances
public double[] getDistances() throws java.lang.ExceptionReturns the distances for the nearest neighbours in the FILTERED space- Specified by:
getDistancesin classNearestNeighbourSearch- Returns:
- the array of distances for the nearest neighbours
- Throws:
java.lang.Exception- if called before calling kNearestNeighbours or nearestNeighbours.- See Also:
NearestNeighbourSearch.getDistances()
-
update
public void update(Instance ins) throws java.lang.Exception
Updates ranges based on the given instance, once it has been filtered.- Specified by:
updatein classNearestNeighbourSearch- Parameters:
ins- the instance to add- Throws:
java.lang.Exception- if updating fails- See Also:
NearestNeighbourSearch.update(weka.core.Instance)
-
addInstanceInfo
public void addInstanceInfo(Instance ins)
Updates the instance info in the underlying search method, once the instance has been filtered.- Overrides:
addInstanceInfoin classNearestNeighbourSearch- Parameters:
ins- The instance to add the information of.
-
-