Class Classifier
- Direct Known Subclasses:
AbstractWekaClassifier
,LinearClassifier
,MahalanobisClassifier
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
Modifier and TypeClassDescriptionstatic enum
Type of probability that will be returned by this classifier. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
abstract ClassifierParams
Will get called AFTER classifier training to get classifier specific parameters.double[]
Get an array of log likelihoods from the most recent call to runClassification(double[] );double[][]
Get a double array of log likelihoods from the most recent call to runClassification(double[][] );abstract Jama.Matrix
Get a matrix of log likelihoods from the most recent call to RunClassification(Matrix )double
double[]
Get an array of probabilities from the most recent call to runClassification(double[] );double[][]
Get a double array of probabilities from the most recent call to runClassification(double[][] );abstract Jama.Matrix
Get a matrix of probabilities from the most recent call to RunClassification(Matrix )abstract Classifier.ProbabilityType
Get the type of probability returned by a classifier.boolean
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.void
setMinimumProbability
(double minimumProbability) boolean
showParamsDialog
(Window parent) toString()
trainClassification
(double[][] params, int[] group) Train the classifier.abstract String
trainClassification
(Jama.Matrix matrix, int[] group) /** Train the classifier.
-
Constructor Details
-
Classifier
public Classifier()
-
-
Method Details
-
getClassifierParams
Will get called AFTER classifier training to get classifier specific parameters.- Returns:
- classifier specific parameters.
-
setClassifierParams
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
-
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
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
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
/** Train the classifier.- Parameters:
matrix
- matrix of training data (each row one training point, each col one parametergroup
- truthparams
- 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
-
getClassifierName
- Returns:
- the classifier name, e.g. Linear Discriminant Analysis
-