Example usage for weka.core Instances attributeToDoubleArray

List of usage examples for weka.core Instances attributeToDoubleArray

Introduction

In this page you can find the example usage for weka.core Instances attributeToDoubleArray.

Prototype


publicdouble[] attributeToDoubleArray(int index) 

Source Link

Document

Gets the value of all instances in this dataset for a particular attribute.

Usage

From source file:soccer.core.models.BookKeeperConsistency.java

public void setInstances(Instances instances) {
    double[][] result = new double[2756][6];
    for (int j = 0; j < 3; j++) {
        double[][] m = new double[10][2756];
        double[][] transformed = new double[2756][10];
        //            double[] mean = new double[2576];
        //            double[] var = new double[2576];
        for (int i = 0; i < 10; i++) {
            m[i] = instances.attributeToDoubleArray(j + 3 * i);
        }//from w ww  . jav  a2s  . c o  m
        transformed = transposeMatrix(m);
        for (int i = 0; i < 2756; i++) {
            //                mean[i] = StatUtils.mean(transformed[i]);
            //                var[i] = StatUtils.variance(transformed[i], mean[i]);
            double mean = StatUtils.mean(transformed[i]);
            result[i][j + 3] = mean;
            result[i][j] = StatUtils.variance(transformed[i]) / mean;
        }
    }
    for (int i = 0; i < 2756; i++) {
        result[i][0] = result[i][0] + result[i][1] + result[i][2];
        Instance inst = new DenseInstance(1.0, result[i]);
        is.add(inst);
    }
}