org.apache.mahout.common.distance
Class MinkowskiDistanceMeasure
java.lang.Object
org.apache.mahout.common.distance.MinkowskiDistanceMeasure
- All Implemented Interfaces:
- DistanceMeasure, Parametered
public class MinkowskiDistanceMeasure
- extends Object
- implements DistanceMeasure
Implement Minkowski distance, a real-valued generalization of the
integral L(n) distances: Manhattan = L1, Euclidean = L2.
For high numbers of dimensions, very high exponents give more useful distances.
Note: Math.pow is clever about integer-valued doubles.
Fields inherited from interface org.apache.mahout.common.parameters.Parametered |
log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MinkowskiDistanceMeasure
public MinkowskiDistanceMeasure()
MinkowskiDistanceMeasure
public MinkowskiDistanceMeasure(double exponent)
createParameters
public void createParameters(String prefix,
org.apache.hadoop.conf.Configuration conf)
- 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.conf
- configuration used for retrieving values- See Also:
invoking method
,
invoking method
getParameters
public Collection<Parameter<?>> getParameters()
- Specified by:
getParameters
in interface Parametered
configure
public void configure(org.apache.hadoop.conf.Configuration jobConf)
- Specified by:
configure
in interface Parametered
getExponent
public double getExponent()
setExponent
public void setExponent(double exponent)
distance
public double distance(Vector v1,
Vector v2)
- Math.pow is clever about integer-valued doubles
- Specified by:
distance
in interface DistanceMeasure
- Parameters:
v1
- a Vector defining a multidimensional point in some feature spacev2
- 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 centroidcentroid
- Centroid vector
Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.