Class LWLDatasetBuilder

  • All Implemented Interfaces:
    adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.SizeOfHandler, Serializable

    public class LWLDatasetBuilder
    extends adams.core.logging.CustomLoggingLevelObject
    Class for building LWL-style weighted datasets.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  LWLDatasetBuilder.LWLContainer
      the container with the weighted dataset, distances, indices.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.core.neighboursearch.NearestNeighbourSearch m_ActualSearch
      The actual nearest neighbour search algorithm to use.
      protected weka.core.Instances m_ActualTrain
      The actual training instances used for classification.
      protected weka.filters.unsupervised.attribute.AddID m_AddID
      for adding the ID to trace the instances.
      protected int m_kNN
      The number of neighbours used to select the kernel bandwidth.
      protected boolean m_NoUpdate
      whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      protected weka.core.neighboursearch.NearestNeighbourSearch m_Search
      The nearest neighbour search algorithm to use.
      protected weka.core.Instances m_Train
      The training instances used for classification.
      protected boolean m_UseAllK
      True if m_kNN should be set to all instances.
      protected int m_WeightKernel
      The weighting kernel method currently selected.
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      LWLDatasetBuilder.LWLContainer build​(weka.core.Instance instance)
      Constructs the weighted dataset.
      protected String getIDAttributeName​(weka.core.Instances data)
      Returns a unique attribute name for the ID attribute.
      int getKNN()
      Gets the number of neighbours used for kernel bandwidth setting.
      boolean getNoUpdate()
      Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      weka.core.neighboursearch.NearestNeighbourSearch getSearchAlgorithm()
      Returns the current nearestNeighbourSearch algorithm in use.
      weka.core.Instances getTrain()
      Returns the training data in use.
      int getWeightingKernel()
      Gets the kernel weighting method to use.
      protected void reset()
      Resets the scheme.
      void setKNN​(int value)
      Sets the number of neighbours used for kernel bandwidth setting.
      void setNoUpdate​(boolean value)
      Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.
      void setSearchAlgorithm​(weka.core.neighboursearch.NearestNeighbourSearch value)
      Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).
      void setTrain​(weka.core.Instances value)
      Sets the training data to use.
      void setWeightingKernel​(int value)
      Sets the kernel weighting method to use.
      String toString()
      Returns a short string description of the setup.
      • Methods inherited from class adams.core.logging.CustomLoggingLevelObject

        setLoggingLevel
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Field Detail

      • m_Train

        protected weka.core.Instances m_Train
        The training instances used for classification.
      • m_ActualTrain

        protected transient weka.core.Instances m_ActualTrain
        The actual training instances used for classification.
      • m_kNN

        protected int m_kNN
        The number of neighbours used to select the kernel bandwidth.
      • m_WeightKernel

        protected int m_WeightKernel
        The weighting kernel method currently selected.
      • m_UseAllK

        protected boolean m_UseAllK
        True if m_kNN should be set to all instances.
      • m_Search

        protected weka.core.neighboursearch.NearestNeighbourSearch m_Search
        The nearest neighbour search algorithm to use.
      • m_ActualSearch

        protected transient weka.core.neighboursearch.NearestNeighbourSearch m_ActualSearch
        The actual nearest neighbour search algorithm to use.
      • m_NoUpdate

        protected boolean m_NoUpdate
        whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
      • m_AddID

        protected transient weka.filters.unsupervised.attribute.AddID m_AddID
        for adding the ID to trace the instances.
    • Constructor Detail

      • LWLDatasetBuilder

        public LWLDatasetBuilder()
    • Method Detail

      • reset

        protected void reset()
        Resets the scheme.
      • setKNN

        public void setKNN​(int value)
        Sets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.
        Parameters:
        value - the number of neighbours included inside the kernel bandwidth, or 0 to specify using all neighbors.
      • getKNN

        public int getKNN()
        Gets the number of neighbours used for kernel bandwidth setting. The bandwidth is taken as the distance to the kth neighbour.
        Returns:
        the number of neighbours included inside the kernel bandwidth, or 0 for all neighbours
      • setWeightingKernel

        public void setWeightingKernel​(int value)
        Sets the kernel weighting method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT, other values are ignored.
        Parameters:
        value - the new kernel method to use. Must be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
      • getWeightingKernel

        public int getWeightingKernel()
        Gets the kernel weighting method to use.
        Returns:
        the new kernel method to use. Will be one of LINEAR, EPANECHNIKOV, TRICUBE, INVERSE, GAUSS or CONSTANT.
      • setSearchAlgorithm

        public void setSearchAlgorithm​(weka.core.neighboursearch.NearestNeighbourSearch value)
        Sets the nearestNeighbourSearch algorithm to be used for finding nearest neighbour(s).
        Parameters:
        value - - The NearestNeighbourSearch class.
      • getSearchAlgorithm

        public weka.core.neighboursearch.NearestNeighbourSearch getSearchAlgorithm()
        Returns the current nearestNeighbourSearch algorithm in use.
        Returns:
        the NearestNeighbourSearch algorithm currently in use.
      • setNoUpdate

        public void setNoUpdate​(boolean value)
        Sets whether to suppress updating the nearest-neighbor search algorithm when making predictions.
        Parameters:
        value - if true then no update happens.
      • getNoUpdate

        public boolean getNoUpdate()
        Returns whether to suppress the update of the nearest-neighbor search algorithm when making predictions.
        Returns:
        true if the update is suppressed
      • setTrain

        public void setTrain​(weka.core.Instances value)
        Sets the training data to use.
        Parameters:
        value - the data
      • getTrain

        public weka.core.Instances getTrain()
        Returns the training data in use.
        Returns:
        the data
      • getIDAttributeName

        protected String getIDAttributeName​(weka.core.Instances data)
        Returns a unique attribute name for the ID attribute.
        Parameters:
        data - the data to insert the attribute
        Returns:
        the attribute name
      • build

        public LWLDatasetBuilder.LWLContainer build​(weka.core.Instance instance)
                                             throws Exception
        Constructs the weighted dataset.
        Parameters:
        instance - the instance to make prediction for
        Returns:
        the container with the generated for the classifier to train with
        Throws:
        Exception - if build fails
      • toString

        public String toString()
        Returns a short string description of the setup.
        Overrides:
        toString in class Object
        Returns:
        the description