classifier
Class Classifier

java.lang.Object
  extended by classifier.Classifier
Direct Known Subclasses:
LinearClassifier, MahalanobisClassifier

public abstract class Classifier
extends java.lang.Object

Interface for fragment classification. Hopefully, a number of different classifiers will be incorporated and each will work under this general interface.

Assume that each classifier will be able to return 0 - n-1 different species classifications. They will provide a list of which species correspond to those numbers. -1 (for nothing I recognise) will also be a valid classification result.

these classifiers are not thread safe. e.g. When running classifiers, it's likely that you will call one of the runClassification functions which will return the most likely result, but you may follow this up with subsequent calls to getLogLikelyhood() and getProbability() to get more information about individual group probabilities.

Author:
Douglas Gillespie

Nested Class Summary
static class Classifier.ProbabilityType
          Type of probability that will be returned by this classifier.
 
Constructor Summary
Classifier()
           
 
Method Summary
abstract  java.lang.String getClassifierName()
           
abstract  ClassifierParams getClassifierParams()
          Will get called AFTER classifier training to get classifier specific parameters.
 double[] getLogLikelihoods1()
          Get an array of log likelihoods from the most recent call to runClassification(double[] );
 double[][] getLogLikelihoods2()
          Get a double array of log likelihoods from the most recent call to runClassification(double[][] );
abstract  Jama.Matrix getLogLikelihoodsM()
          Get a matrix of log likelihoods from the most recent call to RunClassification(Matrix )
 double[] getProbabilities1()
          Get an array of probabilities from the most recent call to runClassification(double[] );
 double[][] getProbabilities2()
          Get a double array of probabilities from the most recent call to runClassification(double[][] );
abstract  Jama.Matrix getProbabilitiesM()
          Get a matrix of probabilities from the most recent call to RunClassification(Matrix )
abstract  Classifier.ProbabilityType getProbabilityType()
          Get the type of probability returned by a classifier.
 int runClassification(double[] params)
          Run the classification on single parameter value.
 int[] runClassification(double[][] params)
          Run classification on multiple parameter values.
abstract  int[] runClassification(Jama.Matrix data)
           
abstract  boolean setClassifierParams(ClassifierParams classifierParams)
          Will be called to load stored parameters into a classifier.
 java.lang.String toString()
           
 java.lang.String trainClassification(double[][] params, int[] group)
          Train the classifier.
abstract  java.lang.String trainClassification(Jama.Matrix matrix, int[] group)
          /** Train the classifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Classifier

public Classifier()
Method Detail

getClassifierParams

public abstract ClassifierParams getClassifierParams()
Will get called AFTER classifier training to get classifier specific parameters.

Returns:
classifier specific parameters.

setClassifierParams

public abstract boolean setClassifierParams(ClassifierParams classifierParams)
Will be called to load stored parameters into a classifier.

Parameters:
classifierParams - classifier parameters.
Returns:
Return true if parameters loaded OK. Reasons for not loading include the classifier being incompatible with the classifier parameters or the parameters not being present (e.t. null matrixes)

runClassification

public int runClassification(double[] params)
Run the classification on single parameter value.

Return true if the classification completed OK, false otherwise. The classification results can be obtained through calls to getClassLikelyhoods() and getBestSpeciesBet();

Parameters:
params - array of input parameters
Returns:
true if classification completed successfully.

runClassification

public int[] runClassification(double[][] params)
Run classification on multiple parameter values.

Parameters:
params - array of input parameters
Returns:
true if completed successfully

runClassification

public abstract int[] runClassification(Jama.Matrix data)

getLogLikelihoods1

public double[] getLogLikelihoods1()
Get an array of log likelihoods from the most recent call to runClassification(double[] );

This version will return a single row of data, which should be from a single classification

Returns:
array of likelihoods

getLogLikelihoods2

public double[][] getLogLikelihoods2()
Get a double array of log likelihoods from the most recent call to runClassification(double[][] );

This version will return a 2D array of data, which should be from a set of classifications

Returns:
array of likelihoods

getLogLikelihoodsM

public abstract Jama.Matrix getLogLikelihoodsM()
Get a matrix of log likelihoods from the most recent call to RunClassification(Matrix )

This version will return a matrix of data, which should be from a set of classifications.

Returns:
log likelihoods matrix.

getProbabilities1

public double[] getProbabilities1()
Get an array of probabilities from the most recent call to runClassification(double[] );

This version will return a single row of data, which should be from a single classification

Returns:
array of probabilities

getProbabilities2

public double[][] getProbabilities2()
Get a double array of probabilities from the most recent call to runClassification(double[][] );

This version will return a 2D array of data, which should be from a set of classifications

Returns:
array of probabilities

getProbabilitiesM

public abstract Jama.Matrix getProbabilitiesM()
Get a matrix of probabilities from the most recent call to RunClassification(Matrix )

This version will return a matrix of data, which should be from a set of classifications.

Returns:
probabilities matrix.

getProbabilityType

public abstract Classifier.ProbabilityType getProbabilityType()
Get the type of probability returned by a classifier. this will either be NORMALISED, ABSOLUTE or UNAVAILABLE in which case the classifier should still return data (to stop things crashing) but should return arrays / Matrixes with zeros in all columns except the selected item, which should be 1.

Returns:
type of probability returned.

trainClassification

public java.lang.String trainClassification(double[][] params,
                                            int[] group)
Train the classifier.

Parameters:
params - double array of input data, each row representing one training value, and each column one parameter value.
truth -
Returns:
null if OK, or error string

trainClassification

public abstract java.lang.String trainClassification(Jama.Matrix matrix,
                                                     int[] group)
/** Train the classifier.

Parameters:
params - double array of input data, each row representing one training value, and each column one parameter value.
matrix - matrix of training data (each row one training point, each col one parameter
group - truth
Returns:
null if OK or error string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getClassifierName

public abstract java.lang.String getClassifierName()
Returns:
the classifier name, e.g. Linear Discriminant Analysis