Package weka.core.neighboursearch
Class FilteredSearch
- java.lang.Object
-
- weka.core.neighboursearch.NearestNeighbourSearch
-
- weka.core.neighboursearch.NewNNSearch
-
- weka.core.neighboursearch.TransformNNSearch
-
- weka.core.neighboursearch.FilteredSearch
-
- All Implemented Interfaces:
Serializable,weka.core.AdditionalMeasureProducer,weka.core.OptionHandler,weka.core.RevisionHandler
- Direct Known Subclasses:
FilteredSearchWithIndices
public class FilteredSearch extends TransformNNSearch
Class implementing the brute force search algorithm for nearest neighbour search, filtered using PLS.
Valid options are:
-S Skip identical instances (distances equal to zero).
- Version:
- $Revision$
- Author:
- Dale
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class weka.core.neighboursearch.NewNNSearch
NewNNSearch.InstanceNode
-
Nested classes/interfaces inherited from class weka.core.neighboursearch.NearestNeighbourSearch
weka.core.neighboursearch.NearestNeighbourSearch.MyHeap, weka.core.neighboursearch.NearestNeighbourSearch.MyHeapElement, weka.core.neighboursearch.NearestNeighbourSearch.NeighborList, weka.core.neighboursearch.NearestNeighbourSearch.NeighborNode
-
-
Field Summary
Fields Modifier and Type Field Description protected weka.filters.Filterm_FilterThe filter-
Fields inherited from class weka.core.neighboursearch.TransformNNSearch
m_myInstances
-
Fields inherited from class weka.core.neighboursearch.NewNNSearch
m_Distances, m_neighbours, m_SkipIdentical
-
-
Constructor Summary
Constructors Constructor Description FilteredSearch()Constructor.FilteredSearch(weka.core.Instances insts)Constructor that uses the supplied set of instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInstanceInfo(weka.core.Instance ins)Adds the given instance info.StringfilterTipText()Returns the tip text for this propertyweka.filters.FiltergetFilter()Gets the filter used.protected StringgetFilterSpec()Gets the filter specification string, which contains the class name of the filter and any options to the filterString[]getOptions()Gets the current settings.weka.core.InstanceskNearestNeighbours(weka.core.Instance target, int kNN)Returns k nearest instances in the current neighbourhood to the supplied instance.EnumerationlistOptions()Returns an enumeration describing the available options.voidsetFilter(weka.filters.Filter filter)Sets the filtervoidsetInstances(weka.core.Instances insts)Sets the instances comprising the current neighbourhood.voidsetOptions(String[] options)Parses a given list of options.weka.core.InstancetransformInstance(weka.core.Instance in)protected weka.core.InstancestransformInstances(weka.core.Instances in)voidupdate(weka.core.Instance ins)Updates the LinearNNSearch to cater for the new added instance.-
Methods inherited from class weka.core.neighboursearch.TransformNNSearch
getTransformedInstances
-
Methods inherited from class weka.core.neighboursearch.NewNNSearch
getDistances, getRevision, getSkipIdentical, globalInfo, nearestNeighbour, setSkipIdentical, skipIdenticalTipText
-
Methods inherited from class weka.core.neighboursearch.NearestNeighbourSearch
combSort11, distanceFunctionTipText, enumerateMeasures, getDistanceFunction, getInstances, getMeasure, getMeasurePerformance, getPerformanceStats, measurePerformanceTipText, partition, quickSort, setDistanceFunction, setMeasurePerformance
-
-
-
-
Constructor Detail
-
FilteredSearch
public FilteredSearch()
Constructor. Needs setInstances(Instances) to be called before the class is usable.
-
FilteredSearch
public FilteredSearch(weka.core.Instances insts)
Constructor that uses the supplied set of instances.- Parameters:
insts- the instances to use
-
-
Method Detail
-
transformInstances
protected weka.core.Instances transformInstances(weka.core.Instances in) throws Exception- Throws:
Exception
-
transformInstance
public weka.core.Instance transformInstance(weka.core.Instance in) throws Exception- Specified by:
transformInstancein classTransformNNSearch- Throws:
Exception
-
kNearestNeighbours
public weka.core.Instances kNearestNeighbours(weka.core.Instance target, int kNN) throws ExceptionReturns k nearest instances in the current neighbourhood to the supplied instance.- Overrides:
kNearestNeighboursin classNewNNSearch- Parameters:
target- The instance to find the k nearest neighbours for.kNN- The number of nearest neighbours to find.- Returns:
- the k nearest neighbors
- Throws:
Exception- if the neighbours could not be found.
-
setInstances
public void setInstances(weka.core.Instances insts) throws ExceptionSets the instances comprising the current neighbourhood.- Overrides:
setInstancesin classNewNNSearch- Parameters:
insts- The set of instances on which the nearest neighbour search is carried out. Usually this set is the training set.- Throws:
Exception- if setting of instances fails
-
update
public void update(weka.core.Instance ins) throws ExceptionUpdates the LinearNNSearch to cater for the new added instance. This implementation only updates the ranges of the DistanceFunction class, since our set of instances is passed by reference and should already have the newly added instance.- Overrides:
updatein classNewNNSearch- Parameters:
ins- The instance to add. Usually this is the instance that is added to our neighbourhood i.e. the training instances.- Throws:
Exception- if the given instances are null
-
addInstanceInfo
public void addInstanceInfo(weka.core.Instance ins)
Adds the given instance info. This implementation updates the range datastructures of the DistanceFunction class.- Overrides:
addInstanceInfoin classNewNNSearch- Parameters:
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.
-
listOptions
public Enumeration listOptions()
Description copied from class:NewNNSearchReturns an enumeration describing the available options.- Specified by:
listOptionsin interfaceweka.core.OptionHandler- Overrides:
listOptionsin classNewNNSearch- Returns:
- an enumeration of all the available options.
-
filterTipText
public 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(weka.filters.Filter filter)
Sets the filter- Parameters:
filter- the filter with all options set.
-
getFilter
public weka.filters.Filter getFilter()
Gets the filter used.- Returns:
- the filter
-
getFilterSpec
protected String getFilterSpec()
Gets the filter specification string, which contains the class name of the filter and any options to the filter- Returns:
- the filter string.
-
setOptions
public void setOptions(String[] options) throws Exception
Description copied from class:NewNNSearchParses a given list of options.
Valid options are:
-S Skip identical instances (distances equal to zero).
- Specified by:
setOptionsin interfaceweka.core.OptionHandler- Overrides:
setOptionsin classNewNNSearch- Parameters:
options- the list of options as an array of strings- Throws:
Exception- if an option is not supported
-
getOptions
public String[] getOptions()
Description copied from class:NewNNSearchGets the current settings.- Specified by:
getOptionsin interfaceweka.core.OptionHandler- Overrides:
getOptionsin classNewNNSearch- Returns:
- an array of strings suitable for passing to setOptions()
-
-