weka.core.neighboursearch
Class PCANNSearch

java.lang.Object
  extended by weka.core.neighboursearch.NearestNeighbourSearch
      extended by weka.core.neighboursearch.NewNNSearch
          extended by weka.core.neighboursearch.PCANNSearch
All Implemented Interfaces:
Serializable, weka.core.AdditionalMeasureProducer, weka.core.OptionHandler, weka.core.RevisionHandler

public class PCANNSearch
extends NewNNSearch

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: 4584 $
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
protected  double m_CoverVariance
          the amount of varaince to cover in the original data when retaining the best n PC's.
protected  int m_MaxAttrsInName
          maximum number of attributes in the transformed attribute name.
protected  weka.core.Instances m_myInstances
           
protected  weka.filters.unsupervised.attribute.PrincipalComponents m_pca
          The neighbourhood of instances to find neighbours in.
protected  int m_Preprocessing
          the type of preprocessing
 
Fields inherited from class weka.core.neighboursearch.NewNNSearch
m_Distances, m_neighbours, m_SkipIdentical
 
Fields inherited from class weka.core.neighboursearch.NearestNeighbourSearch
m_DistanceFunction, m_Instances, m_kNN, m_MeasurePerformance, m_Stats
 
Constructor Summary
PCANNSearch()
          Constructor.
PCANNSearch(weka.core.Instances insts)
          Constructor that uses the supplied set of instances.
 
Method Summary
 void addInstanceInfo(weka.core.Instance ins)
          Adds the given instance info.
protected  weka.filters.unsupervised.attribute.PrincipalComponents buildFilter(double cv, int maxatt)
           
 int getMaximumAttributeNames()
          Gets maximum number of attributes to include in transformed attribute names.
 String[] getOptions()
          Gets the current settings.
 double getVarianceCovered()
          Gets the proportion of total variance to account for when retaining principal components.
 weka.core.Instances kNearestNeighbours(weka.core.Instance target, int kNN)
          Returns k nearest instances in the current neighbourhood to the supplied instance.
 Enumeration listOptions()
          Returns an enumeration describing the available options.
 void setInstances(weka.core.Instances insts)
          Sets the instances comprising the current neighbourhood.
 void setMaximumAttributeNames(int value)
          Sets maximum number of attributes to include in transformed attribute names.
 void setOptions(String[] options)
          Parses a given list of options.
 void setPreprocessing(weka.core.SelectedTag value)
          Sets the type of preprocessing to use
 void setVarianceCovered(double value)
          Sets the amount of variance to account for when retaining principal components.
protected  weka.core.Instance transformInstance(weka.core.Instance in)
           
protected  weka.core.Instances transformInstances(weka.core.Instances in)
           
 void update(weka.core.Instance ins)
          Updates the LinearNNSearch to cater for the new added instance.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_pca

protected weka.filters.unsupervised.attribute.PrincipalComponents m_pca
The neighbourhood of instances to find neighbours in.


m_CoverVariance

protected double m_CoverVariance
the amount of varaince to cover in the original data when retaining the best n PC's.


m_MaxAttrsInName

protected int m_MaxAttrsInName
maximum number of attributes in the transformed attribute name.


m_myInstances

protected weka.core.Instances m_myInstances

m_Preprocessing

protected int m_Preprocessing
the type of preprocessing

Constructor Detail

PCANNSearch

public PCANNSearch()
Constructor. Needs setInstances(Instances) to be called before the class is usable.


PCANNSearch

public PCANNSearch(weka.core.Instances insts)
Constructor that uses the supplied set of instances.

Parameters:
insts - the instances to use
Method Detail

setVarianceCovered

public void setVarianceCovered(double value)
Sets the amount of variance to account for when retaining principal components.

Parameters:
value - the proportion of total variance to account for

getVarianceCovered

public double getVarianceCovered()
Gets the proportion of total variance to account for when retaining principal components.

Returns:
the proportion of variance to account for

setMaximumAttributeNames

public void setMaximumAttributeNames(int value)
Sets maximum number of attributes to include in transformed attribute names.

Parameters:
value - the maximum number of attributes

getMaximumAttributeNames

public int getMaximumAttributeNames()
Gets maximum number of attributes to include in transformed attribute names.

Returns:
the maximum number of attributes

transformInstances

protected weka.core.Instances transformInstances(weka.core.Instances in)
                                          throws Exception
Throws:
Exception

transformInstance

protected weka.core.Instance transformInstance(weka.core.Instance in)
                                        throws Exception
Throws:
Exception

buildFilter

protected weka.filters.unsupervised.attribute.PrincipalComponents buildFilter(double cv,
                                                                              int maxatt)

kNearestNeighbours

public weka.core.Instances kNearestNeighbours(weka.core.Instance target,
                                              int kNN)
                                       throws Exception
Returns k nearest instances in the current neighbourhood to the supplied instance.

Overrides:
kNearestNeighbours in class NewNNSearch
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 Exception
Sets the instances comprising the current neighbourhood.

Overrides:
setInstances in class NewNNSearch
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 Exception
Updates 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:
update in class NewNNSearch
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:
addInstanceInfo in class NewNNSearch
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: NewNNSearch
Returns an enumeration describing the available options.

Specified by:
listOptions in interface weka.core.OptionHandler
Overrides:
listOptions in class NewNNSearch
Returns:
an enumeration of all the available options.

setPreprocessing

public void setPreprocessing(weka.core.SelectedTag value)
Sets the type of preprocessing to use

Parameters:
value - the preprocessing type

setOptions

public void setOptions(String[] options)
                throws Exception
Description copied from class: NewNNSearch
Parses a given list of options.

Valid options are:

 -S
  Skip identical instances (distances equal to zero).
 

Specified by:
setOptions in interface weka.core.OptionHandler
Overrides:
setOptions in class NewNNSearch
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: NewNNSearch
Gets the current settings.

Specified by:
getOptions in interface weka.core.OptionHandler
Overrides:
getOptions in class NewNNSearch
Returns:
an array of strings suitable for passing to setOptions()


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.