weka.gui.explorer

## Class ClassifierErrorsPlotInstances

- java.lang.Object
- - weka.gui.explorer.AbstractPlotInstances
  - - weka.gui.explorer.ClassifierErrorsPlotInstances

- All Implemented Interfaces:
    java.io.Serializable, OptionHandler

      public class ClassifierErrorsPlotInstances
      extends AbstractPlotInstances

  A class for generating plottable visualization errors.

  Example usage:

       Instances train = ... // from somewhere
       Instances test = ... // from somewhere
       Classifier cls = ... // from somewhere
       // build classifier
       cls.buildClassifier(train);
       // evaluate classifier and generate plot instances
       ClassifierPlotInstances plotInstances = new ClassifierPlotInstances();
       plotInstances.setClassifier(cls);
       plotInstances.setInstances(train);
       plotInstances.setClassIndex(train.classIndex());
       plotInstances.setUp();
       Evaluation eval = new Evaluation(train);
       for (int i = 0; i < test.numInstances(); i++)
         plotInstances.process(test.instance(i), cls, eval);
       // generate visualization
       VisualizePanel visPanel = new VisualizePanel();
       visPanel.addPlot(plotInstances.getPlotData("plot name"));
       visPanel.setColourIndex(plotInstances.getPlotInstances().classIndex()+1);
       // clean up
       plotInstances.cleanUp();

  Version:
    $Revision: 10220 $
  Author:
    fracpete (fracpete at waikato dot ac dot nz)
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassifierErrorsPlotInstances()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanUp()` For freeing up memory.
    `Classifier` | `getClassifier()` Returns the currently set classifier.
    `int` | `getClassIndex()` Returns the 0-based class index.
    `Evaluation` | `getEvaluation()` Returns the Evaluation object in use.
    `java.util.ArrayList<java.lang.Integer>` | `getPlotShapes()` Get the vector of plot shapes (see weka.gui.visualize.Plot2D).
    `java.util.ArrayList<java.lang.Object>` | `getPlotSizes()` Get the vector of plot sizes (see weka.gui.visualize.Plot2D).
    `boolean` | `getPointSizeProportionalToMargin()` Get whether the point size should be proportional to the prediction margin (classification only).
    `boolean` | `getSaveForVisualization()` Returns whether the instances are saved for visualization for only evaluation of the prediction is to happen.
    `void` | `process(Instance toPredict, Classifier classifier, Evaluation eval)` Process a classifier's prediction for an instance and update a set of plotting instances and additional plotting info.
    `void` | `process(Instances batch, double[][] predictions, Evaluation eval)`
    `void` | `setClassifier(Classifier value)` Sets the classifier used for making the predictions.
    `void` | `setClassIndex(int index)` Sets the 0-based class index.
    `void` | `setEvaluation(Evaluation value)` Sets the Evaluation object to use.
    `void` | `setPlotShapes(java.util.ArrayList<java.lang.Integer> plotShapes)` Set the vector of plot shapes to use;
    `void` | `setPlotSizes(java.util.ArrayList<java.lang.Object> plotSizes)` Set the vector of plot sizes to use
    `void` | `setPointSizeProportionalToMargin(boolean b)` Set whether the point size should be proportional to the prediction margin (classification only).
    `void` | `setSaveForVisualization(boolean value)` Sets whether the instances are saved for visualization or only evaluation of the prediction is to happen.

    - ### Methods inherited from class weka.gui.explorer.AbstractPlotInstances

      `canPlot, getInstances, getOptions, getPlotData, getPlotInstances, listOptions, setInstances, setOptions, setUp`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClassifierErrorsPlotInstances

          public ClassifierErrorsPlotInstances()

  - ### Method Detail

    - #### getPlotShapes

          public java.util.ArrayList<java.lang.Integer> getPlotShapes()

      Get the vector of plot shapes (see weka.gui.visualize.Plot2D).
      Returns:
        the vector of plot shapes.

    - #### getPlotSizes

          public java.util.ArrayList<java.lang.Object> getPlotSizes()

      Get the vector of plot sizes (see weka.gui.visualize.Plot2D).
      Returns:
        the vector of plot sizes.

    - #### setPlotShapes

          public void setPlotShapes(java.util.ArrayList<java.lang.Integer> plotShapes)

      Set the vector of plot shapes to use;
      Parameters:
        `plotShapes` -

    - #### setPlotSizes

          public void setPlotSizes(java.util.ArrayList<java.lang.Object> plotSizes)

      Set the vector of plot sizes to use
      Parameters:
        `plotSizes` - the plot sizes to use

    - #### setClassifier

          public void setClassifier(Classifier value)

      Sets the classifier used for making the predictions.
      Parameters:
        `value` - the classifier to use

    - #### getClassifier

          public Classifier getClassifier()

      Returns the currently set classifier.
      Returns:
        the classifier in use

    - #### setClassIndex

          public void setClassIndex(int index)

      Sets the 0-based class index.
      Parameters:
        `index` - the class index

    - #### getClassIndex

          public int getClassIndex()

      Returns the 0-based class index.
      Returns:
        the class index

    - #### setEvaluation

          public void setEvaluation(Evaluation value)

      Sets the Evaluation object to use.
      Parameters:
        `value` - the evaluation to use

    - #### getEvaluation

          public Evaluation getEvaluation()

      Returns the Evaluation object in use.
      Returns:
        the evaluation object

    - #### setSaveForVisualization

          public void setSaveForVisualization(boolean value)

      Sets whether the instances are saved for visualization or only evaluation of the prediction is to happen.
      Parameters:
        `value` - if true then the instances will be saved

    - #### getSaveForVisualization

          public boolean getSaveForVisualization()

      Returns whether the instances are saved for visualization for only evaluation of the prediction is to happen.
      Returns:
        true if the instances are saved

    - #### setPointSizeProportionalToMargin

          public void setPointSizeProportionalToMargin(boolean b)

      Set whether the point size should be proportional to the prediction margin (classification only).
      Parameters:
        `b` - true if the point size should be proportional to the margin

    - #### getPointSizeProportionalToMargin

          public boolean getPointSizeProportionalToMargin()

      Get whether the point size should be proportional to the prediction margin (classification only).
      Returns:
        true if the point size should be proportional to the margin

    - #### process

          public void process(Instances batch,
                     double[][] predictions,
                     Evaluation eval)

    - #### process

          public void process(Instance toPredict,
                     Classifier classifier,
                     Evaluation eval)

      Process a classifier's prediction for an instance and update a set of plotting instances and additional plotting info. m_PlotShape for nominal class datasets holds shape types (actual data points have automatic shape type assignment; classifier error data points have box shape type). For numeric class datasets, the actual data points are stored in m_PlotInstances and m_PlotSize stores the error (which is later converted to shape size values).
      Parameters:
        `toPredict` - the actual data point
        `classifier` - the classifier
        `eval` - the evaluation object to use for evaluating the classifier on the instance to predict
      See Also:
        `m_PlotShapes`, `m_PlotSizes`, `AbstractPlotInstances.m_PlotInstances`

    - #### cleanUp

          public void cleanUp()

      For freeing up memory. Plot data cannot be generated after this call!
      Overrides:
        `cleanUp` in class `AbstractPlotInstances`