List of usage examples for weka.core Instances meanOrMode
publicdouble meanOrMode(Attribute att)
From source file:transformation.mimlTOml.ArithmeticTransformation.java
License:Open Source License
@Override public Instance transformInstance(Bag bag) throws Exception { int labelIndices[] = dataset.getLabelIndices(); Instance newInst = new DenseInstance(template.numAttributes()); // sets the bagLabel newInst.setDataset(bag.dataset()); // Sets the reference to the dataset newInst.setValue(0, bag.value(0));//w w w . j a v a 2 s. c om // retrieves instances (relational value) Instances instances = bag.getBagAsInstances(); // For all attributes in bag for (int j = 0, attIdx = 1; j < instances.numAttributes(); j++, attIdx++) { double value = instances.meanOrMode(j); newInst.setValue(attIdx, value); } // Insert label information into the instance for (int j = 0; j < labelIndices.length; j++) { newInst.setValue(updatedLabelIndices[j], bag.value(labelIndices[j])); } return newInst; }