edu.stanford.nlp.ie.pnp
Class ConfusionMatrixPlotter
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--edu.stanford.nlp.ie.pnp.ConfusionMatrixPlotter
- All Implemented Interfaces:
- Accessible, ImageObserver, MenuContainer, Printable, Serializable
- public class ConfusionMatrixPlotter
- extends JPanel
- implements Printable
Visualization utility for confusion matrices. Pops up a frame with a 2x2 table
visualizing each count in the confusion matrix as a circle with area proportional to count.
This way (a) it's easy to see where the big and small cells are, and (b) since the radius of
the circle is proportional to the square-root of the count, you get a bit of a scaling where
large values aren't WAY bigger than small values (sort of like with a log-transform).
To use: java ConfusionMatrixPlotter data-filename
where the first line in data-filename
looks like the following: # categories
(where # is the appropriate number), and the remaining
lines of data-filename
each have a row of the confusion matrix, with the values separated by spaces or tabs.
Here is an example data file:
4 categories
619 1 24 16
2 332 2 7
7 0 429 56
5 2 22 501
Free parameters:
- Fraction of cell size that should be taken up by largest circle (i.e. scale factor)
- Colors:
- background color
- circle fill color
- circle border color
- label font color
- circle border width
- See Also:
- Serialized Form
Constructor Summary |
ConfusionMatrixPlotter(JFrame parent,
int[][] values)
Constructs a new ConfusionMatrixPlotter for the given frame with the given
confusion matrix of data. |
Method Summary |
static int |
getMaxValue(int[][] values)
Returns the largest value in the given matrix. |
static void |
main(String[] args)
Opens a new JFrame for a ConfusionMatrixPlotter to display the contents of the given file. |
int |
print(Graphics g,
PageFormat pf,
int pi)
Paints the confusion matrix for printout. |
static int[][] |
readValuesFromFile(String filename)
Reads in a File for a confusion matrix and returns an int[][] with the values. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
strokeColor
public static final Color strokeColor
fillColor
public static final Color fillColor
bgColor
public static final Color bgColor
labelColor
public static final Color labelColor
ConfusionMatrixPlotter
public ConfusionMatrixPlotter(JFrame parent,
int[][] values)
- Constructs a new ConfusionMatrixPlotter for the given frame with the given
confusion matrix of data.
print
public int print(Graphics g,
PageFormat pf,
int pi)
throws PrinterException
- Paints the confusion matrix for printout.
- Specified by:
print
in interface Printable
PrinterException
readValuesFromFile
public static int[][] readValuesFromFile(String filename)
throws FileNotFoundException,
IOException
- Reads in a File for a confusion matrix and returns an int[][] with the values.
The first line of the file should be "# categories" where # is the right number.
The next lines should be one row at a time, with values separated by spaces or tabs.
FileNotFoundException
IOException
getMaxValue
public static int getMaxValue(int[][] values)
- Returns the largest value in the given matrix.
main
public static void main(String[] args)
- Opens a new JFrame for a ConfusionMatrixPlotter to display the contents of the given file.
Usage: java ConfusionMatrixPlotter data-filename
Stanford NLP Group