List of usage examples for weka.core.matrix DoubleVector size
public int size()
From source file:tml.utils.DistanceLib.java
License:Apache License
public static double jaccard(Instance inst1, Instance inst2) { DoubleVector x = new DoubleVector(inst1.toDoubleArray()); DoubleVector y = new DoubleVector(inst2.toDoubleArray()); double intersection = 0.0; for (int i = 0; i < x.size(); i++) { intersection += Math.min(x.get(i), y.get(i)); }//from www . j a v a 2 s . co m if (intersection > 0.0) { double union = x.norm1() + y.norm1() - intersection; return intersection / union; } else { return 0.0; } }