Example usage for weka.core.matrix DoubleVector get

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

Introduction

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

Prototype

public double get(int i) 

Source Link

Document

Gets a single element.

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));
    }/*  w  w w  . j  a v  a2s.  com*/
    if (intersection > 0.0) {
        double union = x.norm1() + y.norm1() - intersection;
        return intersection / union;
    } else {
        return 0.0;
    }
}