Package adams.data.io.input
Class WekaClassifierModelReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractObjectReader
-
- adams.data.io.input.WekaClassifierModelReader
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,FileFormatHandler,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Serializable
public class WekaClassifierModelReader extends AbstractObjectReader
Reads Weka classifiers from serialized files.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intm_Iterationsthe number of warm up iterations to perform.protected booleanm_WarmUpwhether to perform warm up.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description WekaClassifierModelReader()Default constructor.WekaClassifierModelReader(boolean warmUp)Convenience constructor for setting the warmup flag.WekaClassifierModelReader(boolean warmUp, int iterations)Convenience constructor for configuring the warmup.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddefineOptions()Adds options to the internal list of options.protected ObjectdoRead(PlaceholderFile file)Performs the actual reading of the object file.AbstractObjectWritergetCorrespondingWriter()Returns, if available, the corresponding writer.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.intgetIterations()Returns the number of warm up iterations to perform.booleangetWarmUp()Returns whether to warm up the model with a dummy instance after deserializing it.StringglobalInfo()Returns a string describing the object.StringiterationsTipText()Returns the tip text for this property.protected booleanperformWarmUp(weka.core.Instances header, weka.classifiers.Classifier cls)Creates a dummy instance based on the header and attempts to classify it in order to warm up the classifier.voidsetIterations(int value)Sets the number of warm up iterations to perform.voidsetWarmUp(boolean value)Sets whether to warm up the model with a dummy instance after deserializing it.StringwarmUpTipText()Returns the tip text for this property.-
Methods inherited from class adams.data.io.input.AbstractObjectReader
check, getDefaultFormatExtension, getReaders, isAvailable, read
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Constructor Detail
-
WekaClassifierModelReader
public WekaClassifierModelReader()
Default constructor.
-
WekaClassifierModelReader
public WekaClassifierModelReader(boolean warmUp)
Convenience constructor for setting the warmup flag.- Parameters:
warmUp- whether to perform warmup
-
WekaClassifierModelReader
public WekaClassifierModelReader(boolean warmUp, int iterations)Convenience constructor for configuring the warmup.- Parameters:
warmUp- whether to perform warmupiterations- the number of iterations to perform
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
setWarmUp
public void setWarmUp(boolean value)
Sets whether to warm up the model with a dummy instance after deserializing it.- Parameters:
value- true if to warm up
-
getWarmUp
public boolean getWarmUp()
Returns whether to warm up the model with a dummy instance after deserializing it.- Returns:
- true if to warm up
-
warmUpTipText
public String warmUpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setIterations
public void setIterations(int value)
Sets the number of warm up iterations to perform.- Parameters:
value- the number of iterations
-
getIterations
public int getIterations()
Returns the number of warm up iterations to perform.- Returns:
- the number of iterations
-
iterationsTipText
public String iterationsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescriptionin interfaceFileFormatHandler- Specified by:
getFormatDescriptionin classAbstractObjectReader- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceFileFormatHandler- Specified by:
getFormatExtensionsin classAbstractObjectReader- Returns:
- the extension (without the dot!)
-
getCorrespondingWriter
public AbstractObjectWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriterin classAbstractObjectReader- Returns:
- the writer, null if none available
-
performWarmUp
protected boolean performWarmUp(weka.core.Instances header, weka.classifiers.Classifier cls)Creates a dummy instance based on the header and attempts to classify it in order to warm up the classifier.- Parameters:
header- the header to usecls- the classifier to warm up- Returns:
- true if successfully warmed up
-
doRead
protected Object doRead(PlaceholderFile file)
Performs the actual reading of the object file.- Specified by:
doReadin classAbstractObjectReader- Parameters:
file- the file to read- Returns:
- the object, null if failed to read
-
-