org.apache.mahout.common.distance
Class MahalanobisDistanceMeasure

java.lang.Object
  extended by org.apache.mahout.common.distance.MahalanobisDistanceMeasure
All Implemented Interfaces:
DistanceMeasure, Parametered

public class MahalanobisDistanceMeasure
extends Object
implements DistanceMeasure


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mahout.common.parameters.Parametered
Parametered.ParameteredGeneralizations
 
Field Summary
 
Fields inherited from interface org.apache.mahout.common.parameters.Parametered
log
 
Constructor Summary
MahalanobisDistanceMeasure()
           
 
Method Summary
 void configure(org.apache.hadoop.conf.Configuration jobConf)
           
 void createParameters(String prefix, org.apache.hadoop.conf.Configuration jobConf)
          EXPERT: consumers should never have to call this method.
 double distance(double centroidLengthSquare, Vector centroid, Vector v)
          Optimized version of distance metric for sparse vectors.
 double distance(Vector v)
           
 double distance(Vector v1, Vector v2)
          Returns the distance metric applied to the arguments
 Matrix getInverseCovarianceMatrix()
           
 Vector getMeanVector()
           
 Collection<Parameter<?>> getParameters()
           
 void setCovarianceMatrix(Matrix m)
          Computes the inverse covariance from the input covariance matrix given in input.
 void setInverseCovarianceMatrix(Matrix inverseCovarianceMatrix)
           
 void setMeanVector(Vector meanVector)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MahalanobisDistanceMeasure

public MahalanobisDistanceMeasure()
Method Detail

configure

public void configure(org.apache.hadoop.conf.Configuration jobConf)
Specified by:
configure in interface Parametered

getParameters

public Collection<Parameter<?>> getParameters()
Specified by:
getParameters in interface Parametered

createParameters

public void createParameters(String prefix,
                             org.apache.hadoop.conf.Configuration jobConf)
Description copied from interface: Parametered
EXPERT: consumers should never have to call this method. It would be friendly visible to Parametered.ParameteredGeneralizations if java supported it. Calling this method should create a new list of parameters and is called

Specified by:
createParameters in interface Parametered
Parameters:
prefix - ends with a dot if not empty.
jobConf - configuration used for retrieving values
See Also:
invoking method, invoking method

distance

public double distance(Vector v)
Parameters:
v - The vector to compute the distance to
Returns:
Mahalanobis distance of a multivariate vector

distance

public double distance(Vector v1,
                       Vector v2)
Description copied from interface: DistanceMeasure
Returns the distance metric applied to the arguments

Specified by:
distance in interface DistanceMeasure
Parameters:
v1 - a Vector defining a multidimensional point in some feature space
v2 - a Vector defining a multidimensional point in some feature space
Returns:
a scalar doubles of the distance

distance

public double distance(double centroidLengthSquare,
                       Vector centroid,
                       Vector v)
Description copied from interface: DistanceMeasure
Optimized version of distance metric for sparse vectors. This distance computation requires operations proportional to the number of non-zero elements in the vector instead of the cardinality of the vector.

Specified by:
distance in interface DistanceMeasure
Parameters:
centroidLengthSquare - Square of the length of centroid
centroid - Centroid vector

setInverseCovarianceMatrix

public void setInverseCovarianceMatrix(Matrix inverseCovarianceMatrix)

setCovarianceMatrix

public void setCovarianceMatrix(Matrix m)
Computes the inverse covariance from the input covariance matrix given in input.

Parameters:
m - A covariance matrix.
Throws:
IllegalArgumentException - if eigen values equal to 0 found.

getInverseCovarianceMatrix

public Matrix getInverseCovarianceMatrix()

setMeanVector

public void setMeanVector(Vector meanVector)

getMeanVector

public Vector getMeanVector()


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.