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:
adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.io.FileFormatHandler,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.SizeOfHandler,Serializable
public class WekaClassifierModelReader extends adams.data.io.input.AbstractObjectReaderReads 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.
-
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(adams.core.io.PlaceholderFile file)Performs the actual reading of the object file.adams.data.io.output.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
-
-
-
-
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 interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
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 interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatDescriptionin classadams.data.io.input.AbstractObjectReader- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensionsin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatExtensionsin classadams.data.io.input.AbstractObjectReader- Returns:
- the extension (without the dot!)
-
getCorrespondingWriter
public adams.data.io.output.AbstractObjectWriter getCorrespondingWriter()
Returns, if available, the corresponding writer.- Specified by:
getCorrespondingWriterin classadams.data.io.input.AbstractObjectReader- 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(adams.core.io.PlaceholderFile file)
Performs the actual reading of the object file.- Specified by:
doReadin classadams.data.io.input.AbstractObjectReader- Parameters:
file- the file to read- Returns:
- the object, null if failed to read
-
-