Imp
[using it]
Interface Manipulation Package v4.0 (2008-06-25) a-projector ©copyright Author


imp.classifier
Class Classifier

java.lang.Object
  extended by imp.classifier.Classifier
Direct Known Subclasses:
SvmClassifier, YgClassifier, YgPolynomialClassifier

public class Classifier
extends Object

Defines a numerical data classifier.

Formally this may be defined as a function: double[dim] -> String which associated to a numerical value vector a category given as a string.
Very easily a user construct a classifier and: as defined by the proposed methods.
As a basic mechanism a nearest-neighbor classifier is implemented
Classifiers based on this interface should overwrite:


Nested Class Summary
static class Classifier.Data
          Defines a classifier data set.
 
Constructor Summary
Classifier()
          Constructs a raw-classifier (nearest-neighbor classifier).
 
Method Summary
 Classifier add(double[] data, String category, double prob)
          Add a data calibration sample and return this.
 String getCategory(double[] data)
          Get the category for a given input.
 Classifier.Data getData()
          Returns the current calibration data set.
 int getIndex(double[] data)
          Performs a classification
This method is called when a data category is requested.
 double getMargin(double[] data, String category)
          Estimates the margin of a given sample.
 String getName(int index)
          Gets the name of a category.
 String toString()
          Returns a string view of this classifier as a XML text with some classifier properties.
 void train(Classifier.Data data)
          Performs the classifier training
This method is automatically called, after calibration samples have been added and before the next data category request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Classifier

public Classifier()
Constructs a raw-classifier (nearest-neighbor classifier).

Method Detail

add

public final Classifier add(double[] data,
                            String category,
                            double prob)
Add a data calibration sample and return this.

Parameters:
data - calibration input value.
category - [optional, default is ""] category name or "" if the category is undefined.
prob - [optional, default is 1] Sample precision probability: 1 for an exact sample, 0 for an undefined sample.

getCategory

public final String getCategory(double[] data)
Get the category for a given input.

Parameters:
data - data input value.
Returns:
The category name or "" if no classification available.

getData

public Classifier.Data getData()
Returns the current calibration data set.


getIndex

public int getIndex(double[] data)
Performs a classification
This method is called when a data category is requested.

Parameters:
data - data input value.
Returns:
The category index or -1 if no classification available.

getMargin

public double getMargin(double[] data,
                        String category)
Estimates the margin of a given sample.

Parameters:
data - sample data.
category - sample category.
Returns:
The sample margin estimate (i.e. the distance from this sample to a the closest sample of another category after which the classification fail)

getName

public String getName(int index)
Gets the name of a category.

Parameters:
index - The category index.
Returns:
The category name.

toString

public String toString()
Returns a string view of this classifier as a XML text with some classifier properties.

Overrides:
toString in class Object

train

public void train(Classifier.Data data)
Performs the classifier training
This method is automatically called, after calibration samples have been added and before the next data category request.

Parameters:
data - [optional, default is the current calibration data set] The calibration data set to be used to train the classifier.