nz.ac.waikato.mcennis.rat.graph.algorithm.reusablecores
Class InstanceManipulation

java.lang.Object
  extended by nz.ac.waikato.mcennis.rat.graph.algorithm.reusablecores.InstanceManipulation

public class InstanceManipulation
extends java.lang.Object

Helper class for performing manipulations of weka Instance and Instances objects.


Constructor Summary
InstanceManipulation()
           
 
Method Summary
static weka.core.Instance instanceConcatenation(weka.core.Instance[] data, weka.core.Instances[] meta)
          Takes the contents of the Instance array and creates a new Instance object whose attributes are the attributes of the Instance objects in sequence backed by a new Dataset relfecting the new set of attributes.
static weka.core.Instance[] normalizeFieldNames(weka.core.Instance[] data, weka.core.Instances[] meta)
          Takes an array of Instance objects and create a new array of Instance objects backed by a single Dataset.
static java.util.LinkedList<weka.core.Instance> propertyToInstance(Property property)
          Transforms a property into an Instance object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceManipulation

public InstanceManipulation()
Method Detail

propertyToInstance

public static java.util.LinkedList<weka.core.Instance> propertyToInstance(Property property)
Transforms a property into an Instance object. Useful for providing raw Instances for use in aggreator algorithms. The work is farmed out to InstanceFactory objects that perform the transformation based on the class of the values in the property. The InstanceFactoryRegistry object performs the lookup for the right registry. In the event of a null property, empty value list, or a class of object without a factory for transforming into an Instance, an empty LinkedList is returned.

Parameters:
property - property object to be transformed into a Instance.
Returns:
LinkedList of Instance objects representing this property

instanceConcatenation

public static weka.core.Instance instanceConcatenation(weka.core.Instance[] data,
                                                       weka.core.Instances[] meta)
Takes the contents of the Instance array and creates a new Instance object whose attributes are the attributes of the Instance objects in sequence backed by a new Dataset relfecting the new set of attributes. If there is any conflict of attribute names between the Instance objects, they are duplicated in the Instance object (which may cause difficulties for some machine learning algorithms.) If this a problem, utilize normalizeFieldNames instead of concatenation. If either array is null or if the length of the data and meta array do not match, a new Instance object without attributes is created and returned.

Parameters:
data - array of Instance objects
meta - array of Instances backing the data array
Returns:
new Instance containing all the given data

normalizeFieldNames

public static weka.core.Instance[] normalizeFieldNames(weka.core.Instance[] data,
                                                       weka.core.Instances[] meta)
Takes an array of Instance objects and create a new array of Instance objects backed by a single Dataset. When there is no data for a given attribute in the new Dataset, the Instance is assigned the 'missing' value for that attribute. If either array is null or if the length of the data and meta arrays are not the same, an empty array is returned. Otherwise, the length of the returned array is equal to the length of the data array.

Parameters:
data - array of Instance objects to normalize
meta - array of Instances objects backing the objects in the data array
Returns:
new array of Instance objects backed by a single dataset.