Package weka.classifiers.misc
Class SerializedClassifier
java.lang.Object
weka.classifiers.AbstractClassifier
weka.classifiers.misc.SerializedClassifier
- All Implemented Interfaces:
Serializable
,Cloneable
,Classifier
,BatchPredictor
,CapabilitiesHandler
,CapabilitiesIgnorer
,CommandlineRunnable
,OptionHandler
,RevisionHandler
A wrapper around a serialized classifier model.
This classifier loads a serialized models and uses it to make predictions.
Warning: since the serialized model doesn't get changed, cross-validation cannot bet used with this classifier. Valid options are:
Warning: since the serialized model doesn't get changed, cross-validation cannot bet used with this classifier. Valid options are:
-D If set, classifier is run in debug mode and may output additional info to the console
-model <filename> The file containing the serialized model. (required)
- Version:
- $Revision: 15519 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Field Summary
Fields inherited from class weka.classifiers.AbstractClassifier
BATCH_SIZE_DEFAULT, NUM_DECIMAL_PLACES_DEFAULT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
buildClassifier
(Instances data) loads only the serialized classifierdouble[]
distributionForInstance
(Instance instance) Calculates the class membership probabilities for the given test instance.Returns default capabilities of the base classifier.Gets the currently loaded model (can be null).Gets the file containing the serialized model.String[]
returns the options of the current setupReturns the revision string.Returns a string describing classifierGets an enumeration describing the available options.static void
Runs the classifier with the given optionsReturns the tip text for this propertyvoid
setModel
(Classifier value) Sets the fully built model to use, if one doesn't want to load a model from a file or already deserialized a model from somewhere else.void
setModelFile
(File value) Sets the file containing the serialized model.void
setOptions
(String[] options) Parses the options for this object.toString()
Returns a string representation of the classifierMethods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, classifyInstance, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
Constructor Details
-
SerializedClassifier
public SerializedClassifier()
-
-
Method Details
-
globalInfo
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
listOptions
Gets an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classAbstractClassifier
- Returns:
- an enumeration of all the available options.
-
getOptions
returns the options of the current setup- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classAbstractClassifier
- Returns:
- the current options
-
setOptions
Parses the options for this object. Valid options are:-D If set, classifier is run in debug mode and may output additional info to the console
-model <filename> The file containing the serialized model. (required)
- Specified by:
setOptions
in interfaceOptionHandler
- Overrides:
setOptions
in classAbstractClassifier
- Parameters:
options
- the options to use- Throws:
Exception
- if setting of options fails
-
modelFileTipText
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getModelFile
Gets the file containing the serialized model.- Returns:
- the file.
-
setModelFile
Sets the file containing the serialized model.- Parameters:
value
- the file.
-
setModel
Sets the fully built model to use, if one doesn't want to load a model from a file or already deserialized a model from somewhere else.- Parameters:
value
- the built model- See Also:
-
getCurrentModel
Gets the currently loaded model (can be null). Call buildClassifier method to load model from file.- Returns:
- the current model
- See Also:
-
getCapabilities
Returns default capabilities of the base classifier.- Specified by:
getCapabilities
in interfaceCapabilitiesHandler
- Specified by:
getCapabilities
in interfaceClassifier
- Overrides:
getCapabilities
in classAbstractClassifier
- Returns:
- the capabilities of the base classifier
- See Also:
-
distributionForInstance
Calculates the class membership probabilities for the given test instance.- Specified by:
distributionForInstance
in interfaceClassifier
- Overrides:
distributionForInstance
in classAbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- preedicted class probability distribution
- Throws:
Exception
- if distribution can't be computed successfully
-
buildClassifier
loads only the serialized classifier- Parameters:
data
- the training instances- Throws:
Exception
- if something goes wrong
-
toString
Returns a string representation of the classifier -
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classAbstractClassifier
- Returns:
- the revision
-
main
Runs the classifier with the given options- Parameters:
args
- the commandline options
-