Hi all,
I have attempted to write a method centroid() that
1) sums a HashSet of org.apache.mahout.math.Vector (vectors that are
DenseVector), and
2) (org.apache.mahout.math.Vector.divide) divides the summed vector by
its size, as a double.
I get an error:
Exception in thread "main" java.lang.IncompatibleClassChangeError:
class org.apache.mahout.math.function.Functions$1 has interface
org.apache.mahout.math.function.DoubleFunction as super class
I've tried this with a set of DenseVector and
SequentialAccessSparseVector with the same result.
Any help appreciated, the actual method is below.
I noticed a class Centroid in the mahout distribution, but seems to
cover a different sense of centroid than that I'm implementing here.
Thanks,
Patrice
public Vector centroid (HashSet<Vector> vectors){
Iterator<Vector> it = vectors.iterator();
Vector sum = it.next();
while(it.hasNext()){
Vector aVector = it.next();
sum = sum.plus(aVector);
System.out.println(sum.toString());
}
Integer totalVectors = vectors.size();
double dlTotalVectors = totalVectors.doubleValue();
return sum.divide(dlTotalVectors);
}
