SerializedClassifier (original) (raw)
java.lang.Object
- weka.classifiers.Classifier
- weka.classifiers.misc.SerializedClassifier
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, CapabilitiesHandler, OptionHandler, RevisionHandler
public class SerializedClassifier
extends Classifier
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:
-D
If set, classifier is run in debug mode and
may output additional info to the console
-model
The file containing the serialized model.
(required)
Version: Revision:7560Revision: 7560 Revision:7560
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form
Constructor Summary
Constructors
Constructor and Description SerializedClassifier() Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method and Description void buildClassifier(Instances data) loads only the serialized classifier double[] distributionForInstance(Instance instance) Calculates the class membership probabilities for the given test instance. Capabilities getCapabilities() Returns default capabilities of the base classifier. Classifier getCurrentModel() Gets the currently loaded model (can be null). java.io.File getModelFile() Gets the file containing the serialized model. java.lang.String[] getOptions() returns the options of the current setup java.lang.String getRevision() Returns the revision string. java.lang.String globalInfo() Returns a string describing classifier java.util.Enumeration listOptions() Gets an enumeration describing the available options. static void main(java.lang.String[] args) Runs the classifier with the given options java.lang.String modelFileTipText() Returns the tip text for this property void 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(java.io.File value) Sets the file containing the serialized model. void setOptions(java.lang.String[] options) Parses the options for this object. java.lang.String toString() Returns a string representation of the classifier * ### Methods inherited from class weka.classifiers.[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers") `[classifyInstance](../../../weka/classifiers/Classifier.html#classifyInstance-weka.core.Instance-), [debugTipText](../../../weka/classifiers/Classifier.html#debugTipText--), [forName](../../../weka/classifiers/Classifier.html#forName-java.lang.String-java.lang.String:A-), [getDebug](../../../weka/classifiers/Classifier.html#getDebug--), [makeCopies](../../../weka/classifiers/Classifier.html#makeCopies-weka.classifiers.Classifier-int-), [makeCopy](../../../weka/classifiers/Classifier.html#makeCopy-weka.classifiers.Classifier-), [setDebug](../../../weka/classifiers/Classifier.html#setDebug-boolean-)` * ### Methods inherited from class java.lang.Object `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`
Constructor Detail
* #### SerializedClassifier public SerializedClassifier()
Method Detail
* #### globalInfo public java.lang.String globalInfo() Returns a string describing classifier Returns: a description suitable for displaying in the explorer/experimenter gui * #### listOptions public java.util.Enumeration listOptions() Gets an enumeration describing the available options. Specified by: `[listOptions](../../../weka/core/OptionHandler.html#listOptions--)` in interface `[OptionHandler](../../../weka/core/OptionHandler.html "interface in weka.core")` Overrides: `[listOptions](../../../weka/classifiers/Classifier.html#listOptions--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: an enumeration of all the available options. * #### getOptions public java.lang.String[] getOptions() returns the options of the current setup Specified by: `[getOptions](../../../weka/core/OptionHandler.html#getOptions--)` in interface `[OptionHandler](../../../weka/core/OptionHandler.html "interface in weka.core")` Overrides: `[getOptions](../../../weka/classifiers/Classifier.html#getOptions--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: the current options * #### setOptions public void setOptions(java.lang.String[] options) throws java.lang.Exception 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](../../../weka/core/OptionHandler.html#setOptions-java.lang.String:A-)` in interface `[OptionHandler](../../../weka/core/OptionHandler.html "interface in weka.core")` Overrides: `[setOptions](../../../weka/classifiers/Classifier.html#setOptions-java.lang.String:A-)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Parameters: `options` \- the options to use Throws: `java.lang.Exception` \- if setting of options fails * #### modelFileTipText public java.lang.String modelFileTipText() Returns the tip text for this property Returns: tip text for this property suitable for displaying in the explorer/experimenter gui * #### getModelFile public java.io.File getModelFile() Gets the file containing the serialized model. Returns: the file. * #### setModelFile public void setModelFile(java.io.File value) Sets the file containing the serialized model. Parameters: `value` \- the file. * #### setModel public void setModel([Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers") 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. Parameters: `value` \- the built model See Also: [getCurrentModel()](../../../weka/classifiers/misc/SerializedClassifier.html#getCurrentModel--) * #### getCurrentModel public [Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers") getCurrentModel() Gets the currently loaded model (can be null). Call buildClassifier method to load model from file. Returns: the current model See Also: [setModel(Classifier)](../../../weka/classifiers/misc/SerializedClassifier.html#setModel-weka.classifiers.Classifier-) * #### getCapabilities public [Capabilities](../../../weka/core/Capabilities.html "class in weka.core") getCapabilities() Returns default capabilities of the base classifier. Specified by: `[getCapabilities](../../../weka/core/CapabilitiesHandler.html#getCapabilities--)` in interface `[CapabilitiesHandler](../../../weka/core/CapabilitiesHandler.html "interface in weka.core")` Overrides: `[getCapabilities](../../../weka/classifiers/Classifier.html#getCapabilities--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: the capabilities of the base classifier See Also: [Capabilities](../../../weka/core/Capabilities.html "class in weka.core") * #### distributionForInstance public double[] distributionForInstance([Instance](../../../weka/core/Instance.html "class in weka.core") instance) throws java.lang.Exception Calculates the class membership probabilities for the given test instance. Overrides: `[distributionForInstance](../../../weka/classifiers/Classifier.html#distributionForInstance-weka.core.Instance-)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Parameters: `instance` \- the instance to be classified Returns: preedicted class probability distribution Throws: `java.lang.Exception` \- if distribution can't be computed successfully * #### buildClassifier public void buildClassifier([Instances](../../../weka/core/Instances.html "class in weka.core") data) throws java.lang.Exception loads only the serialized classifier Specified by: `[buildClassifier](../../../weka/classifiers/Classifier.html#buildClassifier-weka.core.Instances-)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Parameters: `data` \- the training instances Throws: `java.lang.Exception` \- if something goes wrong * #### toString public java.lang.String toString() Returns a string representation of the classifier Overrides: `toString` in class `java.lang.Object` Returns: the string representation of the classifier * #### getRevision public java.lang.String getRevision() Returns the revision string. Specified by: `[getRevision](../../../weka/core/RevisionHandler.html#getRevision--)` in interface `[RevisionHandler](../../../weka/core/RevisionHandler.html "interface in weka.core")` Overrides: `[getRevision](../../../weka/classifiers/Classifier.html#getRevision--)` in class `[Classifier](../../../weka/classifiers/Classifier.html "class in weka.classifiers")` Returns: the revision * #### main public static void main(java.lang.String[] args) Runs the classifier with the given options Parameters: `args` \- the commandline options