Example usage for weka.associations Associator buildAssociations

List of usage examples for weka.associations Associator buildAssociations

Introduction

In this page you can find the example usage for weka.associations Associator buildAssociations.

Prototype

void buildAssociations(Instances data) throws Exception;

Source Link

Document

Generates an associator.

Usage

From source file:adams.flow.transformer.WekaTrainAssociator.java

License:Open Source License

/**
 * Executes the flow item./*from w  w  w.  ja  v  a2 s  .  co m*/
 *
 * @return      null if everything is fine, otherwise error message
 */
@Override
protected String doExecute() {
    String result;
    Instances data;
    Instance inst;
    weka.associations.Associator cls;

    result = null;

    try {
        if ((m_InputToken != null) && (m_InputToken.getPayload() instanceof Instances)) {
            cls = getAssociatorInstance();
            data = (Instances) m_InputToken.getPayload();
            cls.buildAssociations(data);
            if ((cls instanceof AssociationRulesProducer) && ((AssociationRulesProducer) cls).canProduceRules())
                m_OutputToken = new Token(new WekaAssociatorContainer(cls, new Instances(data, 0), data,
                        ((AssociationRulesProducer) cls).getAssociationRules().getRules()));
            else
                m_OutputToken = new Token(new WekaAssociatorContainer(cls, new Instances(data, 0), data));
        }
    } catch (Exception e) {
        m_OutputToken = null;
        result = handleException("Failed to process data:", e);
    }

    if (m_OutputToken != null)
        updateProvenance(m_OutputToken);

    return result;
}