Example usage for weka.associations ItemSet setItem

List of usage examples for weka.associations ItemSet setItem

Introduction

In this page you can find the example usage for weka.associations ItemSet setItem.

Prototype

public void setItem(int[] items) 

Source Link

Document

Sets an item sets

Usage

From source file:LabeledItemSet.java

License:Open Source License

/**
 * Generates rules out of item sets/*from   ww w  . ja v  a 2s  . co  m*/
 * @param minConfidence the minimum confidence
 * @param noPrune flag indicating whether the rules are pruned accoridng to the minimum confidence value
 * @return a set of rules
 */
public final FastVector[] generateRules(double minConfidence, boolean noPrune) {

    FastVector premises = new FastVector(), consequences = new FastVector(), conf = new FastVector();
    FastVector[] rules = new FastVector[3];
    ItemSet premise, consequence;

    // Generate all rules with class in the consequence. 
    premise = new ItemSet(m_totalTransactions);
    consequence = new ItemSet(m_totalTransactions);
    int[] premiseItems = new int[m_items.length];
    int[] consequenceItems = new int[1];
    System.arraycopy(m_items, 0, premiseItems, 0, m_items.length);
    consequence.setItem(consequenceItems);
    premise.setItem(premiseItems);
    consequence.setItemAt(m_classLabel, 0);
    consequence.setCounter(this.m_ruleSupCounter);
    premise.setCounter(this.m_counter);
    premises.addElement(premise);
    consequences.addElement(consequence);
    conf.addElement(new Double((double) this.m_ruleSupCounter / (double) this.m_counter));

    rules[0] = premises;
    rules[1] = consequences;
    rules[2] = conf;
    if (!noPrune)
        pruneRules(rules, minConfidence);

    return rules;
}