Class SerializedModelSaver

    • Field Detail

      • FILE_EXTENSION

        public static final String FILE_EXTENSION
        the extension for serialized models (binary Java serialization)
        See Also:
        Constant Field Values
      • s_fileFormatsAvailable

        public static ArrayList<Tag> s_fileFormatsAvailable
        Available file formats. Reflection is used to check if classes are available for deep object serialization to XML
    • Constructor Detail

      • SerializedModelSaver

        public SerializedModelSaver()
        Constructor.
    • Method Detail

      • setCustomName

        public void setCustomName​(String name)
        Set a custom (descriptive) name for this bean
        Specified by:
        setCustomName in interface BeanCommon
        Parameters:
        name - the name to use
      • getCustomName

        public String getCustomName()
        Get the custom (descriptive) name for this bean (if one has been set)
        Specified by:
        getCustomName in interface BeanCommon
        Returns:
        the custom name (or the default name)
      • useDefaultVisual

        public void useDefaultVisual()
        Use the default images for this bean.
        Specified by:
        useDefaultVisual in interface Visible
      • setVisual

        public void setVisual​(BeanVisual newVisual)
        Set the visual for this data source.
        Specified by:
        setVisual in interface Visible
        Parameters:
        newVisual - a BeanVisual value
      • getVisual

        public BeanVisual getVisual()
        Get the visual being used by this data source.
        Specified by:
        getVisual in interface Visible
        Returns:
        a BeanVisual value
      • connectionAllowed

        public boolean connectionAllowed​(EventSetDescriptor esd)
        Returns true if, at this time, the object will accept a connection according to the supplied EventSetDescriptor.
        Specified by:
        connectionAllowed in interface BeanCommon
        Parameters:
        esd - the EventSetDescriptor
        Returns:
        true if the object will accept a connection
      • connectionAllowed

        public boolean connectionAllowed​(String eventName)
        Returns true if, at this time, the object will accept a connection according to the supplied event name.
        Specified by:
        connectionAllowed in interface BeanCommon
        Parameters:
        eventName - the event
        Returns:
        true if the object will accept a connection
      • connectionNotification

        public void connectionNotification​(String eventName,
                                           Object source)
        Notify this object that it has been registered as a listener with a source with respect to the supplied event name.
        Specified by:
        connectionNotification in interface BeanCommon
        Parameters:
        eventName - the event
        source - the source with which this object has been registered as a listener
      • disconnectionNotification

        public void disconnectionNotification​(String eventName,
                                              Object source)
        Notify this object that it has been deregistered as a listener with a source with respect to the supplied event name.
        Specified by:
        disconnectionNotification in interface BeanCommon
        Parameters:
        eventName - the event
        source - the source with which this object has been registered as a listener
      • setLog

        public void setLog​(Logger logger)
        Set a log for this bean.
        Specified by:
        setLog in interface BeanCommon
        Parameters:
        logger - a weka.gui.Logger value
      • stop

        public void stop()
        Stop any processing that the bean might be doing.
        Specified by:
        stop in interface BeanCommon
      • isBusy

        public boolean isBusy()
        Returns true if. at this time, the bean is busy with some (i.e. perhaps a worker thread is performing some calculation).
        Specified by:
        isBusy in interface BeanCommon
        Returns:
        true if the bean is busy.
      • saveBinary

        public static void saveBinary​(File saveTo,
                                      Object model,
                                      Instances header)
                               throws IOException
        Save a model in binary form.
        Parameters:
        saveTo - the file name to save to
        model - the model to save
        header - the header of the data that was used to train the model (optional)
        Throws:
        IOException
      • saveKOML

        public static void saveKOML​(File saveTo,
                                    Object model,
                                    Instances header)
                             throws Exception
        Save a model in KOML deep object serialized XML form.
        Parameters:
        saveTo - the file name to save to
        model - the model to save
        header - the header of the data that was used to train the model (optional)
        Throws:
        Exception
      • saveXStream

        public static void saveXStream​(File saveTo,
                                       Object model,
                                       Instances header)
                                throws Exception
        Save a model in XStream deep object serialized XML form.
        Parameters:
        saveTo - the file name to save to
        model - the model to save
        header - the header of the data that was used to train the model (optional)
        Throws:
        Exception
      • getDirectory

        public File getDirectory()
        Get the directory that the model(s) will be saved into
        Returns:
        the directory to save to
      • setDirectory

        public void setDirectory​(File d)
        Set the directory that the model(s) will be saved into.
        Parameters:
        d - the directory to save to
      • setUseRelativePath

        public void setUseRelativePath​(boolean rp)
        Set whether to use relative paths for the directory. I.e. relative to the startup (user.dir) directory
        Parameters:
        rp - true if relative paths are to be used
      • getUseRelativePath

        public boolean getUseRelativePath()
        Get whether to use relative paths for the directory. I.e. relative to the startup (user.dir) directory
        Returns:
        true if relative paths are to be used
      • setIncludeRelationName

        public 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.
        Parameters:
        rn - true if the relation name should be included in the file name
      • getIncludeRelationName

        public 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.
        Returns:
        true if the relation name is to be included in the file name
      • getPrefix

        public String getPrefix()
        Get the prefix to prepend to the model file names.
        Returns:
        the prefix to prepend
      • setPrefix

        public void setPrefix​(String p)
        Set the prefix to prepend to the model file names.
        Parameters:
        p - the prefix to prepend
      • setIncrementalSaveSchedule

        public void setIncrementalSaveSchedule​(int s)
        Set how often to save incremental models. <= 0 means only at the end of the stream
        Parameters:
        s - how often to save (after every s instances)
      • getIncrementalSaveSchedule

        public int getIncrementalSaveSchedule()
        Get how often to save incremental models. <= 0 means only at the end of the stream
        Returns:
        how often to save (after every s instances)
      • globalInfo

        public String globalInfo()
        Global info for this bean. Gets displayed in the GUI.
        Returns:
        information about this bean.
      • setFileFormat

        public void setFileFormat​(Tag ff)
        Set the file format to use for saving.
        Parameters:
        ff - the file format to use
      • getFileFormat

        public Tag getFileFormat()
        Get the file format to use for saving.
        Returns:
        the file format to use
      • validateFileFormat

        public Tag validateFileFormat​(Tag ff)
        Validate the file format. After this bean is deserialized, classes for XML serialization may not be in the classpath any more.
        Parameters:
        ff - the current file format to validate