You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ka...@apache.org on 2008/04/18 21:47:04 UTC
svn commit: r649667 - in /lucene/mahout/trunk: ./
src/main/java/org/apache/mahout/utils/ src/test/java/org/apache/mahout/utils/
Author: kalle
Date: Fri Apr 18 12:46:55 2008
New Revision: 649667
URL: http://svn.apache.org/viewvc?rev=649667&view=rev
Log:
MAHOUT-36 WeightedDistanceMeasure
Added:
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/AbstractDistanceMeasure.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedDistanceMeasure.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedEuclideanDistanceMeasure.java
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedManhattanDistanceMeasure.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java
lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java
Modified:
lucene/mahout/trunk/build.xml
lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/DistanceMeasure.java
Modified: lucene/mahout/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/build.xml?rev=649667&r1=649666&r2=649667&view=diff
==============================================================================
--- lucene/mahout/trunk/build.xml (original)
+++ lucene/mahout/trunk/build.xml Fri Apr 18 12:46:55 2008
@@ -92,7 +92,7 @@
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
<property name="tests.verbose" value="false"/>
- <property name="junit.excludes" value="**/MatrixTest.java"/>
+ <property name="junit.excludes" value="**/MatrixTest.java, **/DefaultDistanceMeasureTest.java, **/DefaultWeightedDistanceMeasureTest.java"/>
<property name="junit.jar" value="junit-3.8.2.jar"/>
<property name="junit-location.jar" value="${lib}/${junit.jar}"/>
<path id="junit-path">
Added: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/AbstractDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/AbstractDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/AbstractDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/AbstractDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,56 @@
+package org.apache.mahout.utils;
+
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.mahout.matrix.DenseVector;
+import org.apache.mahout.matrix.Vector;
+import org.apache.mahout.matrix.CardinalityException;
+
+/**
+ * Subclasses <b>must</b> implement
+ * either {@link #distance(Float[], Float[])}
+ * or {@link #distance(org.apache.mahout.matrix.Vector, org.apache.mahout.matrix.Vector)}
+ */
+public abstract class AbstractDistanceMeasure implements DistanceMeasure {
+
+
+ public float distance(Float[] p1, Float[] p2) {
+ double[] d1 = new double[p1.length];
+ for (int i = 0; i < p1.length; i++) {
+ d1[i] = p1[i];
+ }
+ double[] d2 = new double[p2.length];
+ for (int i = 0; i < p2.length; i++) {
+ d2[i] = p2[i];
+ }
+ return (float) distance(new DenseVector(d1), new DenseVector(d2));
+ }
+
+
+ public double distance(Vector v1, Vector v2) throws CardinalityException {
+ Float[] f1 = new Float[v1.cardinality()];
+ for (Vector.Element e : v1) {
+ f1[e.index()] = (float)e.get();
+ }
+ Float[] f2 = new Float[v2.cardinality()];
+ for (Vector.Element e : v2) {
+ f2[e.index()] = (float)e.get();
+ }
+ return distance(f1, f2);
+ }
+}
Modified: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/DistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/DistanceMeasure.java?rev=649667&r1=649666&r2=649667&view=diff
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/DistanceMeasure.java (original)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/DistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -32,7 +32,7 @@
* @param p1 a Float[] defining a multidimensional point in some feature space
* @param p2 a Float[] defining a multidimensional point in some feature space
* @return a scalar float of the distance
- * @deprecated in favor of the Vector method
+ * @deprecated use {@link #distance(org.apache.mahout.matrix.Vector, org.apache.mahout.matrix.Vector)}
*/
public float distance(Float[] p1, Float[] p2);
Added: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,79 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.mahout.matrix.DenseVectorWritable;
+import org.apache.mahout.matrix.Vector;
+import org.apache.mahout.matrix.VectorWritable;
+import org.apache.mahout.matrix.SparseVectorWritable;
+
+import java.io.*;
+
+/**
+ * Abstract implementation of DistanceMeasure with support for weights.
+ */
+public abstract class WeightedDistanceMeasure extends AbstractDistanceMeasure {
+
+ protected Vector weights;
+
+ /**
+ * If existing, loads weights using a SparseVectorWritable
+ * from file set in jobConf parameter "org.apache.mahout.utils.WeightedDistanceMeasure.sparseVector"
+ *
+ * todo: should be able to handle any sort of vector. perhaps start the file with what class it is?
+ * todo: some nice static helper method to write and read the file,
+ * todo: or should it be a new writable that decorates any given vector?
+ *
+ * @param jobConf
+ */
+ public void configure(JobConf jobConf) {
+ try {
+ FileSystem fs = FileSystem.get(jobConf);
+ String weightsPathName = WeightedDistanceMeasure.class.getName() + ".sparseVector";
+ if (weightsPathName != null) {
+ VectorWritable writable = new SparseVectorWritable();
+ Path weightsPath = new Path(weightsPathName);
+ if (!fs.exists(weightsPath)) {
+ throw new FileNotFoundException(weightsPath.toString());
+ }
+ DataInputStream in = fs.open(weightsPath);
+ writable.readFields(in);
+ in.close();
+ weights = writable.get();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Vector getWeights() {
+ return weights;
+ }
+
+ public void setWeights(Vector weights) {
+ this.weights = weights;
+ }
+
+
+
+
+}
Added: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedEuclideanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedEuclideanDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedEuclideanDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedEuclideanDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,53 @@
+package org.apache.mahout.utils;
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.mahout.matrix.Vector;
+
+/**
+ * This class implements a Euclidian distance metric by summing the square root
+ * of the squared differences between each coordinate, optionally adding weights.
+ */
+public class WeightedEuclideanDistanceMeasure extends WeightedDistanceMeasure {
+
+ /* (non-Javadoc)
+ * @see org.apache.hadoop.mapred.JobConfigurable#configure(org.apache.hadoop.mapred.JobConf)
+ */
+ public void configure(JobConf job) {
+ super.configure(job);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.mahout.utils.DistanceMeasure#distance(org.apache.mahout.matrix.Vector, org.apache.mahout.matrix.Vector)
+ */
+ public double distance(Vector p1, Vector p2) {
+ double result = 0;
+ Vector res = p2.minus(p1);
+ if (weights == null) {
+ for (int i = 0; i < p1.cardinality(); i++) {
+ result += res.get(i) * res.get(i);
+ }
+ } else {
+ for (int i = 0; i < p1.cardinality(); i++) {
+ result += res.get(i) * res.get(i) * weights.get(i); // todo this is where the weights goes, right?
+ }
+ }
+ return Math.sqrt(result);
+ }
+
+}
Added: lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedManhattanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedManhattanDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedManhattanDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/main/java/org/apache/mahout/utils/WeightedManhattanDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,60 @@
+package org.apache.mahout.utils;
+
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.mahout.matrix.Vector;
+
+/**
+ * This class implements a "manhattan distance" metric by summing the absolute
+ * values of the difference between each coordinate, optionally with weights.
+ */
+public class WeightedManhattanDistanceMeasure extends WeightedDistanceMeasure {
+
+ /* (non-Javadoc)
+ * @see org.apache.mahout.utils.DistanceMeasure#distance(org.apache.mahout.matrix.Vector,
+ * org.apache.mahout.matrix.Vector)
+ */
+ public double distance(Vector p1, Vector p2) {
+ double result = 0;
+
+ Vector res = p2.minus(p1);
+ if (weights == null) {
+ for (int i = 0; i < res.cardinality(); i++) {
+ result += Math.abs(res.get(i));
+ }
+ }
+ else {
+ for (int i = 0; i < res.cardinality(); i++) {
+ result += Math.abs(res.get(i) * weights.get(i)); // todo this is where the weights goes, right?
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.hadoop.mapred.JobConfigurable#configure(org.apache.hadoop.mapred.JobConf)
+ */
+ public void configure(JobConf job) {
+ super.configure(job);
+ }
+
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultDistanceMeasureTest.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+import junit.framework.TestCase;
+import org.apache.mahout.matrix.DenseVector;
+import org.apache.mahout.matrix.Vector;
+
+
+public abstract class DefaultDistanceMeasureTest extends TestCase {
+
+ public abstract DistanceMeasure distanceMeasureFactory();
+
+ public void testMeasure() throws Exception {
+
+ DistanceMeasure distanceMeasure = distanceMeasureFactory();
+
+ Vector[] vectors = new Vector[]{
+ new DenseVector(new double[]{1, 1, 1, 1, 1, 1}),
+ new DenseVector(new double[]{2, 2, 2, 2, 2, 2}),
+ new DenseVector(new double[]{6, 6, 6, 6, 6, 6})
+ };
+
+ double[][] distanceMatrix = new double[3][3];
+
+ for (int a = 0; a < 3; a++) {
+ for (int b = 0; b < 3; b++) {
+ distanceMatrix[a][b] = distanceMeasure.distance(vectors[a], vectors[b]);
+ }
+ }
+
+ assertEquals(0d, distanceMatrix[0][0]);
+ assertTrue(distanceMatrix[0][0] < distanceMatrix[0][1]);
+ assertTrue(distanceMatrix[0][1] < distanceMatrix[0][2]);
+
+ assertEquals(0d, distanceMatrix[1][1]);
+ assertTrue(distanceMatrix[1][0] > distanceMatrix[1][1]);
+ assertTrue(distanceMatrix[1][2] > distanceMatrix[1][0]);
+
+ assertEquals(0d, distanceMatrix[2][2]);
+ assertTrue(distanceMatrix[2][0] > distanceMatrix[2][1]);
+ assertTrue(distanceMatrix[2][1] > distanceMatrix[2][2]);
+
+
+ }
+
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/DefaultWeightedDistanceMeasureTest.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.mahout.utils;
+
+import org.apache.mahout.matrix.DenseVector;
+import org.apache.mahout.matrix.Vector;
+
+public abstract class DefaultWeightedDistanceMeasureTest extends DefaultDistanceMeasureTest {
+
+ public abstract WeightedDistanceMeasure distanceMeasureFactory();
+
+ public void testMeasureWeighted() throws Exception {
+
+ WeightedDistanceMeasure distanceMeasure = distanceMeasureFactory();
+
+ Vector[] vectors = new Vector[]{
+ new DenseVector(new double[]{9, 9, 1}),
+ new DenseVector(new double[]{1, 9, 9}),
+ new DenseVector(new double[]{9, 1, 9}),
+ };
+ distanceMeasure.setWeights(new DenseVector(new double[]{1, 1000, 1}));
+
+ double[][] distanceMatrix = new double[3][3];
+
+ for (int a = 0; a < 3; a++) {
+ for (int b = 0; b < 3; b++) {
+ distanceMatrix[a][b] = distanceMeasure.distance(vectors[a], vectors[b]);
+ }
+ }
+
+ assertEquals(0d, distanceMatrix[0][0]);
+ assertTrue(distanceMatrix[0][1] < distanceMatrix[0][2]);
+
+
+ }
+
+
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestEuclideanDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+public class TestEuclideanDistanceMeasure extends DefaultDistanceMeasureTest {
+
+ public DistanceMeasure distanceMeasureFactory() {
+ return new EuclideanDistanceMeasure();
+ }
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestManhattanDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+public class TestManhattanDistanceMeasure extends DefaultDistanceMeasureTest {
+
+ public DistanceMeasure distanceMeasureFactory() {
+ return new ManhattanDistanceMeasure();
+ }
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedEuclideanDistanceMeasureTest.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+public class TestWeightedEuclideanDistanceMeasureTest extends DefaultWeightedDistanceMeasureTest {
+ public WeightedDistanceMeasure distanceMeasureFactory() {
+ return new WeightedEuclideanDistanceMeasure();
+ }
+}
Added: lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java
URL: http://svn.apache.org/viewvc/lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java?rev=649667&view=auto
==============================================================================
--- lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java (added)
+++ lucene/mahout/trunk/src/test/java/org/apache/mahout/utils/TestWeightedManhattanDistanceMeasure.java Fri Apr 18 12:46:55 2008
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.utils;
+
+public class TestWeightedManhattanDistanceMeasure extends DefaultWeightedDistanceMeasureTest {
+
+
+ public WeightedManhattanDistanceMeasure distanceMeasureFactory() {
+ return new WeightedManhattanDistanceMeasure();
+ }
+}