use of org.knime.core.data.vector.bitvector.BitVectorValue in project knime-core by knime.
the class SubgroupMinerModel method preprocess.
private List<BitVectorValue> preprocess(final DataTable inData, final ExecutionMonitor exec) throws CanceledExecutionException {
// TODO: check in configure that only Double values are in the table
m_tidRowKeyMapping = new HashMap<Integer, RowKey>();
m_nrOfRows = 0;
int totalNrRows = ((BufferedDataTable) inData).getRowCount();
m_maxBitsetLength = 0;
List<BitVectorValue> bitSets = new ArrayList<BitVectorValue>();
int bitVectorIndex = inData.getDataTableSpec().findColumnIndex(m_bitVectorColumn.getStringValue());
if (bitVectorIndex < 0) {
return new ArrayList<BitVectorValue>();
}
for (RowIterator itr = inData.iterator(); itr.hasNext(); ) {
exec.checkCanceled();
DataRow currRow = itr.next();
DataCell dc = currRow.getCell(bitVectorIndex);
if (dc.isMissing()) {
continue;
}
BitVectorValue currCell = ((BitVectorValue) currRow.getCell(bitVectorIndex));
if (currCell.length() > Integer.MAX_VALUE) {
throw new IllegalArgumentException("bit vector in row " + currRow.getKey().getString() + " is too long: " + currCell.length() + ". Only bit vectors up to " + Integer.MAX_VALUE + " are supported by this node.");
}
m_maxBitsetLength = Math.max(m_maxBitsetLength, (int) currCell.length());
bitSets.add(currCell);
m_tidRowKeyMapping.put(m_nrOfRows, currRow.getKey());
m_nrOfRows++;
exec.setProgress((double) m_nrOfRows / (double) totalNrRows, "preprocessing......." + m_nrOfRows);
}
LOGGER.debug("max length: " + m_maxBitsetLength);
return bitSets;
}
use of org.knime.core.data.vector.bitvector.BitVectorValue in project knime-core by knime.
the class SubgroupMinerModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
DataTable input = (BufferedDataTable) inData[0];
ExecutionMonitor exec1 = exec.createSubProgress(0.5);
ExecutionMonitor exec2 = exec.createSubProgress(0.5);
List<BitVectorValue> transactions = preprocess(input, exec1);
m_nameMapping = input.getDataTableSpec().getColumnSpec(m_bitVectorColumn.getStringValue()).getElementNames();
m_apriori = AprioriAlgorithmFactory.getAprioriAlgorithm(AprioriAlgorithmFactory.AlgorithmDataStructure.valueOf(m_underlyingStruct.getStringValue()), m_maxBitsetLength, m_nrOfRows);
LOGGER.debug("support: " + m_minSupport);
LOGGER.debug(m_minSupport + " start apriori: " + new Date());
m_apriori.findFrequentItemSets(transactions, m_minSupport.getDoubleValue(), m_maxItemSetLength.getIntValue(), FrequentItemSet.Type.valueOf(m_itemSetType.getStringValue()), exec2);
LOGGER.debug("ended apriori: " + new Date());
m_itemSetTable = createOutputTable(exec);
return new BufferedDataTable[] { m_itemSetTable };
}
use of org.knime.core.data.vector.bitvector.BitVectorValue in project knime-core by knime.
the class BitVectorNotSetCountOperator method computeInternal.
/**
* {@inheritDoc}
*/
@Override
protected boolean computeInternal(final DataCell cell) {
if (cell instanceof BitVectorValue) {
final BitVectorValue bv = (BitVectorValue) cell;
m_counter += bv.length() - bv.cardinality();
}
return false;
}
use of org.knime.core.data.vector.bitvector.BitVectorValue in project knime-core by knime.
the class BitVectorUnionOperator method computeInternal.
/**
* {@inheritDoc}
*/
@Override
protected boolean computeInternal(final DataCell cell) {
if (cell instanceof BitVectorValue) {
BitVectorValue val = (BitVectorValue) cell;
if (m_v == null) {
m_v = new DenseBitVectorCellFactory(val.length()).createDataCell();
}
m_v = DenseBitVectorCellFactory.or(m_v, val);
}
return false;
}
use of org.knime.core.data.vector.bitvector.BitVectorValue in project knime-core by knime.
the class BitVectorSetCountOperator method computeInternal.
/**
* {@inheritDoc}
*/
@Override
protected boolean computeInternal(final DataCell cell) {
if (cell instanceof BitVectorValue) {
final BitVectorValue bv = (BitVectorValue) cell;
m_counter += bv.cardinality();
}
return false;
}
Aggregations