Class 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 Detail

      • FilteredNeighbourSearch

        public FilteredNeighbourSearch()
    • Method Detail

      • globalInfo

        public java.lang.String globalInfo()
        Returns a string describing this object.
        Overrides:
        globalInfo in class NearestNeighbourSearch
        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
      • getOptions

        public java.lang.String[] getOptions()
        Gets the current settings. Returns empty array.
        Specified by:
        getOptions in interface OptionHandler
        Overrides:
        getOptions in class NearestNeighbourSearch
        Returns:
        an array of strings suitable for passing to setOptions()
      • setOptions

        public void setOptions​(java.lang.String[] options)
                        throws java.lang.Exception
        Parses a given list of options.
        Specified by:
        setOptions in interface OptionHandler
        Overrides:
        setOptions in class NearestNeighbourSearch
        Parameters:
        options - the list of options as an array of strings
        Throws:
        java.lang.Exception - if an option is not supported
      • getDistances

        public double[] getDistances()
                              throws java.lang.Exception
        Returns the distances for the nearest neighbours in the FILTERED space
        Specified by:
        getDistances in class NearestNeighbourSearch
        Returns:
        the array of distances for the nearest neighbours
        Throws:
        java.lang.Exception - if called before calling kNearestNeighbours or nearestNeighbours.
        See Also:
        NearestNeighbourSearch.getDistances()
      • addInstanceInfo

        public void addInstanceInfo​(Instance ins)
        Updates the instance info in the underlying search method, once the instance has been filtered.
        Overrides:
        addInstanceInfo in class NearestNeighbourSearch
        Parameters:
        ins - The instance to add the information of.