Example usage for weka.core Attribute relation

List of usage examples for weka.core Attribute relation

Introduction

In this page you can find the example usage for weka.core Attribute relation.

Prototype

public finalInstances relation() 

Source Link

Document

Returns the header info for a relation-valued attribute, null if the attribute is not relation-valued.

Usage

From source file:de.uni_potsdam.hpi.bpt.promnicat.analysisModules.clustering.ProcessInstances.java

License:Open Source License

/**
 * Create a copy of the structure if the data has string or relational
 * attributes, "cleanses" string types (i.e. doesn't contain references to
 * the strings seen in the past) and all relational attributes.
 * /*from ww w.j a  v a2  s .  c  o  m*/
 * @return a copy of the instance structure.
 */
public ProcessInstances stringFreeStructure() {

    FastVector newAtts = new FastVector();
    for (int i = 0; i < m_Attributes.size(); i++) {
        Attribute att = (Attribute) m_Attributes.elementAt(i);
        if (att.type() == Attribute.STRING) {
            newAtts.addElement(new Attribute(att.name(), (FastVector) null, i));
        } else if (att.type() == Attribute.RELATIONAL) {
            newAtts.addElement(
                    new Attribute(att.name(), new ProcessInstances((ProcessInstances) att.relation(), 0), i));
        }
    }
    if (newAtts.size() == 0) {
        return new ProcessInstances(this, 0);
    }
    FastVector atts = (FastVector) m_Attributes.copy();
    for (int i = 0; i < newAtts.size(); i++) {
        atts.setElementAt(newAtts.elementAt(i), ((Attribute) newAtts.elementAt(i)).index());
    }
    ProcessInstances result = new ProcessInstances(this, 0);
    result.m_Attributes = atts;
    return result;
}