/** * Return a string representation of the rules. * * @param databaseSize the number of transactions in the database where the rules were found. */ public String toString(int databaseSize) { StringBuffer buffer = new StringBuffer(" ------- "); buffer.append(name); buffer.append(" -------\n"); int i = 0; for (Rule rule : rules) { // System.out.println(" L" + j + " "); buffer.append(" rule "); buffer.append(i); buffer.append(": "); buffer.append(rule.toString()); buffer.append("support : "); buffer.append(rule.getRelativeSupport(databaseSize)); buffer.append(" ("); buffer.append(rule.getAbsoluteSupport()); buffer.append("/"); buffer.append(databaseSize); buffer.append(") "); buffer.append("confidence : "); buffer.append(rule.getConfidence()); buffer.append("\n"); i++; } return buffer.toString(); }
/** * Return a string representation of this list of rules * * @param databaseSize the number of transactions in the database where the rules were found. * @return a string */ public String toString(int databaseSize) { // create a string buffer StringBuffer buffer = new StringBuffer(" ------- "); buffer.append(name); buffer.append(" -------\n"); int i = 0; // for each rule for (Rule rule : rules) { // append the rule, its support and confidence. buffer.append(" rule "); buffer.append(i); buffer.append(": "); buffer.append(rule.toString()); buffer.append("support : "); buffer.append(rule.getRelativeSupport(databaseSize)); buffer.append(" ("); buffer.append(rule.getAbsoluteSupport()); buffer.append("/"); buffer.append(databaseSize); buffer.append(") "); buffer.append("confidence : "); buffer.append(rule.getConfidence()); buffer.append("\n"); i++; } return buffer.toString(); // return the string }
/** * Print the rules to System.out * * @param databaseSize the number of transactions in the database where the rules were found. */ public void printRules(int databaseSize) { System.out.println(" ------- " + name + " -------"); int i = 0; for (Rule rule : rules) { System.out.print(" rule " + i + ": " + rule.toString()); System.out.print( "support : " + rule.getRelativeSupport(databaseSize) + " (" + rule.getAbsoluteSupport() + "/" + databaseSize + ") "); System.out.print("confidence : " + rule.getConfidence()); System.out.println(""); i++; } System.out.println(" --------------------------------"); }
/** * Print all the rules in this list to System.out, and include information about the lift measure. * * @param databaseSize the number of transactions in the transaction database where the rules were * found */ public void printRulesWithLift(int objectsCount) { System.out.println(" ------- " + name + " -------"); int i = 0; for (Rule rule : rules) { System.out.print(" rule " + i + ": " + rule.toString()); System.out.print( "support : " + rule.getRelativeSupport(objectsCount) + " (" + rule.getAbsoluteSupport() + "/" + objectsCount + ") "); System.out.print("confidence : " + rule.getConfidence()); System.out.print(" lift : " + rule.getLift()); System.out.println(""); i++; } System.out.println(" --------------------------------"); }