Package weka.classifiers.misc

# Class SerializedClassifier

java.lang.Object
weka.classifiers.Classifier
weka.classifiers.misc.SerializedClassifier

All Implemented Interfaces:
  `Serializable`, `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 <filename>
      The file containing the serialized model.
      (required)

Version:
  $Revision: 7560 $
Author:
  fracpete (fracpete at waikato dot ac dot nz)
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`SerializedClassifier()`

## Method Summary

Modifier and Type
Method
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).
`File`
`getModelFile()`
Gets the file containing the serialized model.
`String[]`
`getOptions()`
returns the options of the current setup
`String`
`getRevision()`
Returns the revision string.
`String`
`globalInfo()`
Returns a string describing classifier
`Enumeration`
`listOptions()`
Gets an enumeration describing the available options.
`static void`
`main(String[] args)`
Runs the classifier with the given options
`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(File value)`
Sets the file containing the serialized model.
`void`
`setOptions(String[] options)`
Parses the options for this object.
`String`
`toString()`
Returns a string representation of the classifier

### Methods inherited from class weka.classifiers.Classifier

`classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### SerializedClassifier

public SerializedClassifier()

## Method Details

### globalInfo

public String globalInfo()
Returns a string describing classifier

Returns:
  a description suitable for displaying in the explorer/experimenter gui

### listOptions

public Enumeration listOptions()
Gets an enumeration describing the available options.

Specified by:
  `listOptions` in interface `OptionHandler`
Overrides:
  `listOptions` in class `Classifier`
Returns:
  an enumeration of all the available options.

### getOptions

public String[] getOptions()
returns the options of the current setup

Specified by:
  `getOptions` in interface `OptionHandler`
Overrides:
  `getOptions` in class `Classifier`
Returns:
  the current options

### setOptions

public void setOptions(String[] options) throws 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` in interface `OptionHandler`
Overrides:
  `setOptions` in class `Classifier`
Parameters:
  `options` - the options to use
Throws:
  `Exception` - if setting of options fails

### modelFileTipText

public 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 File getModelFile()
Gets the file containing the serialized model.

Returns:
  the file.

### setModelFile

public void setModelFile(File value)
Sets the file containing the serialized model.

Parameters:
  `value` - the file.

### setModel

public 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.

Parameters:
  `value` - the built model
See Also:
  - `getCurrentModel()`

### getCurrentModel

public Classifier 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)`

### getCapabilities

public Capabilities getCapabilities()
Returns default capabilities of the base classifier.

Specified by:
  `getCapabilities` in interface `CapabilitiesHandler`
Overrides:
  `getCapabilities` in class `Classifier`
Returns:
  the capabilities of the base classifier
See Also:
  - `Capabilities`

### distributionForInstance

public double[] distributionForInstance(Instance instance) throws Exception
Calculates the class membership probabilities for the given test instance.

Overrides:
  `distributionForInstance` in class `Classifier`
Parameters:
  `instance` - the instance to be classified
Returns:
  preedicted class probability distribution
Throws:
  `Exception` - if distribution can't be computed successfully

### buildClassifier

public void buildClassifier(Instances data) throws Exception
loads only the serialized classifier

Specified by:
  `buildClassifier` in class `Classifier`
Parameters:
  `data` - the training instances
Throws:
  `Exception` - if something goes wrong

### toString

public String toString()
Returns a string representation of the classifier

Overrides:
  `toString` in class `Object`
Returns:
  the string representation of the classifier

### getRevision

public String getRevision()
Returns the revision string.

Specified by:
  `getRevision` in interface `RevisionHandler`
Overrides:
  `getRevision` in class `Classifier`
Returns:
  the revision

### main

public static void main(String[] args)
Runs the classifier with the given options

Parameters:
  `args` - the commandline options