Example usage for weka.core.matrix DoubleVector size

List of usage examples for weka.core.matrix DoubleVector size

Introduction

In this page you can find the example usage for weka.core.matrix DoubleVector size.

Prototype

public int size() 

Source Link

Document

Gets the size of the vector.

Usage

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;
    }
}