Package weka.core.neighboursearch
Class FilteredNeighbourSearch
java.lang.Object
weka.core.neighboursearch.NearestNeighbourSearch
weka.core.neighboursearch.FilteredNeighbourSearch
- All Implemented Interfaces:
Serializable,AdditionalMeasureProducer,CapabilitiesHandler,OptionHandler,RevisionHandler
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInstanceInfo(Instance ins) Updates the instance info in the underlying search method, once the instance has been filtered.Returns the tip text for this propertyReturns default capabilities of the classifier.double[]Returns the distances for the nearest neighbours in the FILTERED spaceGets the filter used.String[]Gets the current settings.Returns the revision stringGets the search method used.Returns a string describing this object.kNearestNeighbours(Instance target, int k) Returns the nearest neighbours for the given instance based on distance measured in the filtered space.Returns an enumeration describing the available options.nearestNeighbour(Instance target) Returns the nearest neighbour for the given instance based on distance measured in the filtered space.Returns the tip text for this propertyvoidSets the filtervoidsetInstances(Instances data) Sets the instances to build the filtering model from.voidsetOptions(String[] options) Parses a given list of options.voidSets the search methodvoidUpdates 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
-
Constructor Details
-
FilteredNeighbourSearch
public FilteredNeighbourSearch()
-
-
Method Details
-
getCapabilities
Returns default capabilities of the classifier.- Specified by:
getCapabilitiesin interfaceCapabilitiesHandler- Returns:
- the capabilities of this classifier
- See Also:
-
setInstances
Sets the instances to build the filtering model from.- Overrides:
setInstancesin classNearestNeighbourSearch- Parameters:
insts- the Instances object
-
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
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setFilter
Sets the filter- Parameters:
filter- the filter with all options set.
-
getFilter
Gets the filter used.- Returns:
- the filter
-
searchMethodTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setSearchMethod
Sets the search method- Parameters:
searchMethod- the search method with all options set.
-
getSearchMethod
Gets the search method used.- Returns:
- the search method
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classNearestNeighbourSearch- Returns:
- an enumeration of all the available options.
-
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
Parses a given list of options.- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classNearestNeighbourSearch- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getRevision
Returns the revision string- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
- See Also:
-
nearestNeighbour
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:
Exception- if the nearest neighbour could not be found.- See Also:
-
kNearestNeighbours
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:
Exception- if the neighbours could not be found.- See Also:
-
getDistances
Returns the distances for the nearest neighbours in the FILTERED space- Specified by:
getDistancesin classNearestNeighbourSearch- Returns:
- the array of distances for the nearest neighbours
- Throws:
Exception- if called before calling kNearestNeighbours or nearestNeighbours.- See Also:
-
update
Updates ranges based on the given instance, once it has been filtered.- Specified by:
updatein classNearestNeighbourSearch- Parameters:
ins- the instance to add- Throws:
Exception- if updating fails- See Also:
-
addInstanceInfo
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.
-