Class BoundaryPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
BoundaryPanelDistributed

public class BoundaryPanel extends JPanel
BoundaryPanel. A class to handle the plotting operations associated with generating a 2D picture of a classifier's decision boundaries.
Since:
1.0
Version:
$Revision: 12565 $
Author:
Mark Hall
See Also:
  • Field Details

    • DEFAULT_COLORS

      public static final Color[] DEFAULT_COLORS
      default colours for classes
    • REMOVE_POINT_RADIUS

      public static final double REMOVE_POINT_RADIUS
      The distance we can click away from a point in the GUI and still remove it.
      See Also:
  • Constructor Details

    • BoundaryPanel

      public BoundaryPanel(int panelWidth, int panelHeight)
      Creates a new BoundaryPanel instance.
      Parameters:
      panelWidth - the width in pixels of the panel
      panelHeight - the height in pixels of the panel
  • Method Details

    • setNumSamplesPerRegion

      public void setNumSamplesPerRegion(int num)
      Set the number of points to uniformly sample from a region (fixed dimensions).
      Parameters:
      num - an int value
    • getNumSamplesPerRegion

      public int getNumSamplesPerRegion()
      Get the number of points to sample from a region (fixed dimensions).
      Returns:
      an int value
    • setGeneratorSamplesBase

      public void setGeneratorSamplesBase(double ksb)
      Set the base for computing the number of samples to obtain from each generator. number of samples = base ^ (# non fixed dimensions)
      Parameters:
      ksb - a double value
    • getGeneratorSamplesBase

      public double getGeneratorSamplesBase()
      Get the base used for computing the number of samples to obtain from each generator
      Returns:
      a double value
    • stopPlotting

      public void stopPlotting()
      Stop the plotting thread
    • computeMinMaxAtts

      public void computeMinMaxAtts()
      Set up the bounds of our graphic based by finding the smallest reasonable area in the instance space to surround our data points.
    • start

      public void start() throws Exception
      Start the plotting thread
      Throws:
      Exception - if an error occurs
    • plotTrainingData

      public void plotTrainingData()
      Render the training points on-screen.
    • setTrainingData

      public void setTrainingData(Instances trainingData) throws Exception
      Set the training data to use
      Parameters:
      trainingData - the training data
      Throws:
      Exception - if an error occurs
    • addTrainingInstance

      public void addTrainingInstance(Instance instance)
      Adds a training instance to the visualization dataset.
    • addActionListener

      public void addActionListener(ActionListener newListener)
      Register a listener to be notified when plotting completes
      Parameters:
      newListener - the listener to add
    • removeActionListener

      public void removeActionListener(ActionListener removeListener)
      Remove a listener
      Parameters:
      removeListener - the listener to remove
    • setClassifier

      public void setClassifier(Classifier classifier)
      Set the classifier to use.
      Parameters:
      classifier - the classifier to use
    • setDataGenerator

      public void setDataGenerator(DataGenerator dataGenerator)
      Set the data generator to use for generating new instances
      Parameters:
      dataGenerator - the data generator to use
    • setXAttribute

      public void setXAttribute(int xatt) throws Exception
      Set the x attribute index
      Parameters:
      xatt - index of the attribute to use on the x axis
      Throws:
      Exception - if an error occurs
    • setYAttribute

      public void setYAttribute(int yatt) throws Exception
      Set the y attribute index
      Parameters:
      yatt - index of the attribute to use on the y axis
      Throws:
      Exception - if an error occurs
    • setColors

      public void setColors(ArrayList<Color> colors)
      Set a vector of Color objects for the classes
      Parameters:
      colors - a FastVector value
    • setPlotTrainingData

      public void setPlotTrainingData(boolean pg)
      Set whether to superimpose the training data plot
      Parameters:
      pg - a boolean value
    • getPlotTrainingData

      public boolean getPlotTrainingData()
      Returns true if training data is to be superimposed
      Returns:
      a boolean value
    • getColors

      public ArrayList<Color> getColors()
      Get the current vector of Color objects used for the classes
      Returns:
      a FastVector value
    • replot

      public void replot()
      Quickly replot the display using cached probability estimates
    • addTrainingInstanceFromMouseLocation

      public void addTrainingInstanceFromMouseLocation(int mouseX, int mouseY, int classAttIndex, double classValue)
      Adds a training instance to our dataset, based on the coordinates of the mouse on the panel. This method sets the x and y attributes and the class (as defined by classAttIndex), and sets all other values as Missing.
      Parameters:
      mouseX - the x coordinate of the mouse, in pixels.
      mouseY - the y coordinate of the mouse, in pixels.
      classAttIndex - the index of the attribute that is currently selected as the class attribute.
      classValue - the value to set the class to in our new point.
    • removeAllInstances

      public void removeAllInstances()
      Deletes all training instances from our dataset.
    • removeTrainingInstanceFromMouseLocation

      public void removeTrainingInstanceFromMouseLocation(int mouseX, int mouseY)
      Removes a single training instance from our dataset, if there is one that is close enough to the specified mouse location.
    • startPlotThread

      public void startPlotThread()
      Starts the plotting thread. Will also create it if necessary.
    • addMouseListener

      public void addMouseListener(MouseListener l)
      Adds a mouse listener.
      Overrides:
      addMouseListener in class Component
    • getMinXBound

      public double getMinXBound()
      Gets the minimum x-coordinate bound, in training-instance units (not mouse coordinates).
    • getMinYBound

      public double getMinYBound()
      Gets the minimum y-coordinate bound, in training-instance units (not mouse coordinates).
    • getMaxXBound

      public double getMaxXBound()
      Gets the maximum x-coordinate bound, in training-instance units (not mouse coordinates).
    • getMaxYBound

      public double getMaxYBound()
      Gets the maximum x-coordinate bound, in training-instance units (not mouse coordinates).
    • main

      public static void main(String[] args)
      Main method for testing this class
      Parameters:
      args - a String[] value