use of org.knime.base.node.mine.subgroupminer.freqitemset.FrequentItemSetRow in project knime-core by knime.
the class SubgroupMinerModel method createFrequentItemsetOutput.
/*
* @return a DataTable cotaining the frequent itemsets and their support
*/
private BufferedDataTable createFrequentItemsetOutput(final ExecutionContext exec) throws CanceledExecutionException {
List<FrequentItemSet> freqSets = m_apriori.getFrequentItemSets(FrequentItemSet.Type.valueOf(m_itemSetType.getStringValue()));
List<FrequentItemSetRow> rows = new LinkedList<FrequentItemSetRow>();
// iterate over set list
int rowKeyCounter = 0;
for (FrequentItemSet set : freqSets) {
exec.setProgress((double) rowKeyCounter / (double) m_nrOfRows, "creating output table. Row number: " + rowKeyCounter);
List<String> itemList = new ArrayList<String>();
for (int i = 0; i < set.getItems().size(); i++) {
if (i > m_maxItemSetLength.getIntValue()) {
break;
}
Integer item = set.getItems().get(i);
// for every item look at the referring column name
String itemName;
if (m_nameMapping != null && m_nameMapping.size() > item) {
itemName = m_nameMapping.get(item);
} else {
itemName = "item" + item;
}
itemList.add(itemName);
}
// create for every set a row
FrequentItemSetRow row = new FrequentItemSetRow(new RowKey("item set " + rowKeyCounter++), itemList, m_maxItemSetLength.getIntValue(), set.getSupport());
rows.add(row);
}
DataTableSpec outSpec = createItemsetOutputSpec();
FrequentItemSetTable result = new FrequentItemSetTable(rows, outSpec);
result.sortBy(FrequentItemSetTable.Sorter.valueOf(m_sorter.getStringValue()));
return exec.createBufferedDataTable(result, exec);
}
Aggregations