org.apache.mahout.common.distance
Class TanimotoDistanceMeasure

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

public class TanimotoDistanceMeasure
extends WeightedDistanceMeasure

Tanimoto coefficient implementation. http://en.wikipedia.org/wiki/Jaccard_index


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
TanimotoDistanceMeasure()
           
 
Method Summary
 double distance(double centroidLengthSquare, Vector centroid, Vector v)
          Optimized version of distance metric for sparse vectors.
 double distance(Vector a, Vector b)
          Calculates the distance between two vectors.
 
Methods inherited from class org.apache.mahout.common.distance.WeightedDistanceMeasure
configure, createParameters, getParameters, getWeights, setWeights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TanimotoDistanceMeasure

public TanimotoDistanceMeasure()
Method Detail

distance

public double distance(Vector a,
                       Vector b)
Calculates the distance between two vectors. The coefficient (a measure of similarity) is: T(a, b) = a.b / (|a|^2 + |b|^2 - a.b) The distance d(a,b) = 1 - T(a,b)

Parameters:
a - a Vector defining a multidimensional point in some feature space
b - a Vector defining a multidimensional point in some feature space
Returns:
0 for perfect match, > 0 for greater 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.

Parameters:
centroidLengthSquare - Square of the length of centroid
centroid - Centroid vector


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