Package classifier

Class Classifier

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

public abstract class Classifier extends 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
  • Constructor Details

    • Classifier

      public Classifier()
  • Method Details

    • 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)
    • hasParamsDialog

      public boolean hasParamsDialog()
    • showParamsDialog

      public boolean showParamsDialog(Window parent)
    • 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.
    • getMinimumProbability

      public double getMinimumProbability()
      Returns:
      the minimumProbability
    • setMinimumProbability

      public void setMinimumProbability(double minimumProbability)
      Parameters:
      minimumProbability - the minimumProbability to set
    • trainClassification

      public 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 String trainClassification(Jama.Matrix matrix, int[] group)
      /** Train the classifier.
      Parameters:
      matrix - matrix of training data (each row one training point, each col one parameter
      group - truth
      params - double array of input data, each row representing one training value, and each column one parameter value.
      Returns:
      null if OK or error string
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getClassifierName

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