org.imirsel.m2k.modelling
Class Gaussian

java.lang.Object
  extended byorg.imirsel.m2k.modelling.Gaussian
All Implemented Interfaces:
java.io.Serializable

public class Gaussian
extends java.lang.Object
implements java.io.Serializable

A single Gaussian classifier with diagonal covariance

Author:
kw
See Also:
Serialized Form

Constructor Summary
Gaussian()
          Creates a new instance of Gaussian
Gaussian(Gaussian oldGaussian)
          Copy constructor for a Gaussian
Gaussian(int numClasses_)
          Creates a new instance of Gaussian
 
Method Summary
 int classify(double[] inputVector)
          Calculates the mahalanobis distances of the inputVector from each class and returns the integer class label of the closest class
 double mahalanobis(double[] vec, double[] means, double[] covars)
          Calculates the mahalanobis distance of the input vector from the means and covariances of the Gaussian model supplied
 void train(double[][] inputData, int[] labels)
          Trains the Gaussian model using diagonal covariance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Gaussian

public Gaussian()
Creates a new instance of Gaussian


Gaussian

public Gaussian(int numClasses_)
Creates a new instance of Gaussian

Parameters:
numClasses_ - Num of classes classifier is to be trained on

Gaussian

public Gaussian(Gaussian oldGaussian)
Copy constructor for a Gaussian

Parameters:
oldGaussian - The Gaussian to copied
Method Detail

classify

public int classify(double[] inputVector)
Calculates the mahalanobis distances of the inputVector from each class and returns the integer class label of the closest class

Parameters:
inputVector - The vector to be classified
Returns:
the integer class label of the closest class

train

public void train(double[][] inputData,
                  int[] labels)
Trains the Gaussian model using diagonal covariance

Parameters:
inputData - The data to train the model on
labels - The class labels of the input data

mahalanobis

public double mahalanobis(double[] vec,
                          double[] means,
                          double[] covars)
Calculates the mahalanobis distance of the input vector from the means and covariances of the Gaussian model supplied

Parameters:
vec - The vector to calculate the mahalanobis distance for
means - The means of the Gaussian model to test against
covars - The covariances of the Gaussian model to test against
Returns:
The mahalanobis distance