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 int
m_Iterations
the number of warm up iterations to perform.protected boolean
m_WarmUp
whether 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 void
defineOptions()
Adds options to the internal list of options.protected Object
doRead(PlaceholderFile file)
Performs the actual reading of the object file.AbstractObjectWriter
getCorrespondingWriter()
Returns, if available, the corresponding writer.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.int
getIterations()
Returns the number of warm up iterations to perform.boolean
getWarmUp()
Returns whether to warm up the model with a dummy instance after deserializing it.String
globalInfo()
Returns a string describing the object.String
iterationsTipText()
Returns the tip text for this property.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.void
setIterations(int value)
Sets the number of warm up iterations to perform.void
setWarmUp(boolean value)
Sets whether to warm up the model with a dummy instance after deserializing it.String
warmUpTipText()
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:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in 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:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in classAbstractObjectReader
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in classAbstractObjectReader
- Returns:
- the extension (without the dot!)
-
getCorrespondingWriter
public AbstractObjectWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriter
in 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:
doRead
in classAbstractObjectReader
- Parameters:
file
- the file to read- Returns:
- the object, null if failed to read
-
-