## milk.classifiers
Class MIClassifier

    java.lang.Object
      |
      +--milk.classifiers.MIClassifier

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable

Direct Known Subclasses:
  DD, MDD, MIBoost, MILR, MILRARITH, MILRGEOM, MINND, MIRBFNetwork, MIWrapper, TLD, TLDSimple

public abstract class MIClassifier
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Abstract classifier. All schemes for numeric or nominal prediction in Weka extend this class.

See Also:
  Serialized Form

Constructor Summary
`MIClassifier()`

Method Summary
`abstract void` `buildClassifier(Exemplars data)` Generates a classifier.
`double` `classifyExemplar(Exemplar example)` Classifies the given test instance.
`double[]` `distributionForExemplar(Exemplar example)` Predicts the class memberships for a given exemplar.
`static MIClassifier` `forName(java.lang.String classifierName, java.lang.String[] options)` Creates a new instance of a classifier given it's class name and (optional) arguments to pass to it's setOptions method.
`static MIClassifier[]` `makeCopies(MIClassifier model, int num)` Creates copies of the current classifier, which can then be used for boosting etc.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MIClassifier

    public MIClassifier()

Method Detail

### buildClassifier

    public abstract void buildClassifier(Exemplars data)
                                  throws java.lang.Exception

  Generates a classifier. Must initialize all fields of the classifier that are not being set via options (ie. multiple calls of buildClassifier must always lead to the same result). Must not change the dataset in any way.

  Parameters:
    `data` - set of exemplars serving as training data
  Throws:
    `java.lang.Exception` - if the classifier has not been generated successfully

### distributionForExemplar

    public double[] distributionForExemplar(Exemplar example)
                                     throws java.lang.Exception

  Predicts the class memberships for a given exemplar. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value. Classifiers have to implement either this or classifyExemplar().

  Parameters:
    `example` - the instance to be classified
  Returns:
    an array containing the estimated membership probabilities of the test instance in each class (this should sum to at most 1)
  Throws:
    `java.lang.Exception` - if distribution could not be computed successfully

### classifyExemplar

    public double classifyExemplar(Exemplar example)
                            throws java.lang.Exception

  Classifies the given test instance. The instance has to belong to a dataset when it's being classified. Classifiers either have to implement this or distributionForExemplar().

  Parameters:
    `example` - the instance to be classified
  Returns:
    the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
  Throws:
    `java.lang.Exception` - if an error occurred during the prediction

### forName

    public static MIClassifier forName(java.lang.String classifierName,
                                       java.lang.String[] options)
                                throws java.lang.Exception

  Creates a new instance of a classifier given it's class name and (optional) arguments to pass to it's setOptions method. If the classifier implements OptionHandler and the options parameter is non-null, the classifier will have it's options set.

  Parameters:
    `classifierName` - the fully qualified class name of the classifier
    `options` - an array of options suitable for passing to setOptions. May be null.
  Returns:
    the newly created MI-classifier, ready for use.
  Throws:
    `java.lang.Exception` - if the classifier name is invalid, or the options supplied are not acceptable to the classifier

### makeCopies

    public static MIClassifier[] makeCopies(MIClassifier model,
                                            int num)
                                     throws java.lang.Exception

  Creates copies of the current classifier, which can then be used for boosting etc. Note that this method now uses Serialization to perform a deep copy, so the Classifier object must be fully Serializable. Any currently built model will now be copied as well.

  Parameters:
    `model` - an example classifier to copy
    `num` - the number of classifiers copies to create.
  Returns:
    an array of MI-classifiers.
  Throws:
    `java.lang.Exception` - if an error occurs