@KFStep(category="DataSinks", toolTipText="Save a batch or incremental model to file") public class SerializedModelSaver extends javax.swing.JPanel implements BeanCommon, Visible, BatchClassifierListener, IncrementalClassifierListener, BatchClustererListener, EnvironmentHandler, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static int |
BINARY |
static java.lang.String |
FILE_EXTENSION
the extension for serialized models (binary Java serialization)
|
static int |
KOMLV |
static java.util.ArrayList<Tag> |
s_fileFormatsAvailable
Available file formats.
|
static int |
XSTREAM |
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
SerializedModelSaver()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptClassifier(BatchClassifierEvent ce)
Accept and save a batch trained classifier.
|
void |
acceptClassifier(IncrementalClassifierEvent ce)
Accept and save an incrementally trained classifier.
|
void |
acceptClusterer(BatchClustererEvent ce)
Accept and save a batch trained clusterer.
|
boolean |
connectionAllowed(java.beans.EventSetDescriptor esd)
Returns true if, at this time, the object will accept a connection
according to the supplied EventSetDescriptor.
|
boolean |
connectionAllowed(java.lang.String eventName)
Returns true if, at this time, the object will accept a connection
according to the supplied event name.
|
void |
connectionNotification(java.lang.String eventName,
java.lang.Object source)
Notify this object that it has been registered as a listener with a source
with respect to the supplied event name.
|
void |
disconnectionNotification(java.lang.String eventName,
java.lang.Object source)
Notify this object that it has been deregistered as a listener with a
source with respect to the supplied event name.
|
java.lang.String |
getCustomName()
Get the custom (descriptive) name for this bean (if one has been set)
|
java.io.File |
getDirectory()
Get the directory that the model(s) will be saved into
|
Tag |
getFileFormat()
Get the file format to use for saving.
|
boolean |
getIncludeRelationName()
Get whether the relation name of the training data used to create the model
is to be included in the filename of the serialized model.
|
int |
getIncrementalSaveSchedule()
Get how often to save incremental models.
|
java.lang.String |
getPrefix()
Get the prefix to prepend to the model file names.
|
boolean |
getUseRelativePath()
Get whether to use relative paths for the directory.
|
BeanVisual |
getVisual()
Get the visual being used by this data source.
|
java.lang.String |
globalInfo()
Global info for this bean.
|
boolean |
isBusy()
Returns true if.
|
static void |
saveBinary(java.io.File saveTo,
java.lang.Object model,
Instances header)
Save a model in binary form.
|
static void |
saveKOML(java.io.File saveTo,
java.lang.Object model,
Instances header)
Save a model in KOML deep object serialized XML form.
|
static void |
saveXStream(java.io.File saveTo,
java.lang.Object model,
Instances header)
Save a model in XStream deep object serialized XML form.
|
void |
setCustomName(java.lang.String name)
Set a custom (descriptive) name for this bean
|
void |
setDirectory(java.io.File d)
Set the directory that the model(s) will be saved into.
|
void |
setEnvironment(Environment env)
Set environment variables to use.
|
void |
setFileFormat(Tag ff)
Set the file format to use for saving.
|
void |
setIncludeRelationName(boolean rn)
Set whether the relation name of the training data used to create the model
should be included as part of the filename for the serialized model.
|
void |
setIncrementalSaveSchedule(int s)
Set how often to save incremental models.
|
void |
setLog(Logger logger)
Set a log for this bean.
|
void |
setPrefix(java.lang.String p)
Set the prefix to prepend to the model file names.
|
void |
setUseRelativePath(boolean rp)
Set whether to use relative paths for the directory.
|
void |
setVisual(BeanVisual newVisual)
Set the visual for this data source.
|
void |
stop()
Stop any processing that the bean might be doing.
|
void |
useDefaultVisual()
Use the default images for this bean.
|
Tag |
validateFileFormat(Tag ff)
Validate the file format.
|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int BINARY
public static final int KOMLV
public static final int XSTREAM
public static final java.lang.String FILE_EXTENSION
public static java.util.ArrayList<Tag> s_fileFormatsAvailable
public void setCustomName(java.lang.String name)
setCustomName
in interface BeanCommon
name
- the name to usepublic java.lang.String getCustomName()
getCustomName
in interface BeanCommon
public void useDefaultVisual()
useDefaultVisual
in interface Visible
public void setVisual(BeanVisual newVisual)
public BeanVisual getVisual()
public boolean connectionAllowed(java.beans.EventSetDescriptor esd)
connectionAllowed
in interface BeanCommon
esd
- the EventSetDescriptorpublic boolean connectionAllowed(java.lang.String eventName)
connectionAllowed
in interface BeanCommon
eventName
- the eventpublic void connectionNotification(java.lang.String eventName, java.lang.Object source)
connectionNotification
in interface BeanCommon
eventName
- the eventsource
- the source with which this object has been registered as a
listenerpublic void disconnectionNotification(java.lang.String eventName, java.lang.Object source)
disconnectionNotification
in interface BeanCommon
eventName
- the eventsource
- the source with which this object has been registered as a
listenerpublic void setLog(Logger logger)
setLog
in interface BeanCommon
logger
- a weka.gui.Logger
valuepublic void stop()
stop
in interface BeanCommon
public boolean isBusy()
isBusy
in interface BeanCommon
public void acceptClusterer(BatchClustererEvent ce)
acceptClusterer
in interface BatchClustererListener
ce
- a BatchClassifierEvent
valuepublic void acceptClassifier(IncrementalClassifierEvent ce)
acceptClassifier
in interface IncrementalClassifierListener
ce
- the BatchClassifierEvent containing the classifierpublic void acceptClassifier(BatchClassifierEvent ce)
acceptClassifier
in interface BatchClassifierListener
ce
- the BatchClassifierEvent containing the classifierpublic static void saveBinary(java.io.File saveTo, java.lang.Object model, Instances header) throws java.io.IOException
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model
(optional)java.io.IOException
public static void saveKOML(java.io.File saveTo, java.lang.Object model, Instances header) throws java.lang.Exception
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model
(optional)java.lang.Exception
public static void saveXStream(java.io.File saveTo, java.lang.Object model, Instances header) throws java.lang.Exception
saveTo
- the file name to save tomodel
- the model to saveheader
- the header of the data that was used to train the model
(optional)java.lang.Exception
public java.io.File getDirectory()
public void setDirectory(java.io.File d)
d
- the directory to save topublic void setUseRelativePath(boolean rp)
rp
- true if relative paths are to be usedpublic boolean getUseRelativePath()
public void setIncludeRelationName(boolean rn)
rn
- true if the relation name should be included in the file namepublic boolean getIncludeRelationName()
public java.lang.String getPrefix()
public void setPrefix(java.lang.String p)
p
- the prefix to prependpublic void setIncrementalSaveSchedule(int s)
s
- how often to save (after every s instances)public int getIncrementalSaveSchedule()
public java.lang.String globalInfo()
public void setFileFormat(Tag ff)
ff
- the file format to usepublic Tag getFileFormat()
public Tag validateFileFormat(Tag ff)
ff
- the current file format to validatepublic void setEnvironment(Environment env)
setEnvironment
in interface EnvironmentHandler
env
- the environment variables to use