use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class PairedTTestStatistics method getTTestTable.
/**
* Get the test result of the t-test.
* @param exec the execution context
* @return the t-test results
*/
public BufferedDataTable getTTestTable(final ExecutionContext exec) {
DataTableSpec outSpec = getTableSpec();
BufferedDataContainer cont = exec.createDataContainer(outSpec);
int r = 0;
for (List<DataCell> cells : getTTestCells()) {
cont.addRowToTable(new DefaultRow(RowKey.createRowKey(r), cells));
r++;
}
cont.close();
BufferedDataTable outTable = cont.getTable();
return outTable;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class PairedTTestStatistics method getDescStatsTable.
/**
* Get descriptive statistics
* @param exec the execution context
* @return the descriptive statistics for each column of the pair
*/
public BufferedDataTable getDescStatsTable(final ExecutionContext exec) {
DataTableSpec outSpec = getDescStatsSpec();
BufferedDataContainer cont = exec.createDataContainer(outSpec);
int r = 0;
for (List<DataCell> cells : getDescStatsCells()) {
cont.addRowToTable(new DefaultRow(RowKey.createRowKey(r), cells));
r++;
}
cont.close();
BufferedDataTable outTable = cont.getTable();
return outTable;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class NewToOldTimeNodeModel method createStreamableOperator.
/**
* {@inheritDoc}
*/
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
return new StreamableOperator() {
@Override
public StreamableOperatorInternals saveInternals() {
return null;
}
@Override
public void runFinal(final PortInput[] inputs, final PortOutput[] outputs, final ExecutionContext exec) throws Exception {
final RowInput in = (RowInput) inputs[0];
final RowOutput out = (RowOutput) outputs[0];
final DataTableSpec inSpec = in.getDataTableSpec();
String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
final int[] includeIndeces = Arrays.stream(includeList).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
DataRow row;
while ((row = in.poll()) != null) {
exec.checkCanceled();
DataCell[] datacells = new DataCell[includeIndeces.length];
for (int i = 0; i < includeIndeces.length; i++) {
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includeList[i], DateAndTimeCell.TYPE);
final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i]);
datacells[i] = cellFac.getCells(row)[0];
} else {
final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includeList[i] + m_suffix.getStringValue(), DateAndTimeCell.TYPE);
final ConvertTimeCellFactory cellFac = new ConvertTimeCellFactory(dataColSpec, includeIndeces[i]);
datacells[i] = cellFac.getCells(row)[0];
}
}
if (m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE)) {
out.push(new ReplacedColumnsDataRow(row, datacells, includeIndeces));
} else {
out.push(new AppendedColumnRow(row, datacells));
}
}
in.close();
out.close();
}
};
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class TwoSampleTTest method execute.
public TwoSampleTTestStatistics[] execute(final BufferedDataTable table, final ExecutionContext exec) throws InvalidSettingsException, CanceledExecutionException {
DataTableSpec spec = table.getDataTableSpec();
int groupingIndex = spec.findColumnIndex(m_grouping.getColumn());
if (groupingIndex == -1) {
throw new InvalidSettingsException("Grouping column not found.");
}
int[] testColumnsIndex = new int[m_testColumns.length];
for (int i = 0; i < testColumnsIndex.length; i++) {
testColumnsIndex[i] = spec.findColumnIndex(m_testColumns[i]);
}
int testColumnCount = m_testColumns.length;
TwoSampleTTestStatistics[] result = new TwoSampleTTestStatistics[testColumnCount];
for (int i = 0; i < testColumnCount; i++) {
result[i] = new TwoSampleTTestStatistics(m_testColumns[i], m_grouping.getGroupLabels(), m_confidenceIntervalProb);
}
final int rowCount = table.getRowCount();
int rowIndex = 0;
for (DataRow row : table) {
exec.checkCanceled();
exec.setProgress(rowIndex++ / (double) rowCount, rowIndex + "/" + rowCount + " (\"" + row.getKey() + "\")");
DataCell groupCell = row.getCell(groupingIndex);
Group group = m_grouping.getGroup(groupCell);
for (int i = 0; i < testColumnCount; i++) {
if (group == null) {
if (groupCell.isMissing()) {
result[i].addMissingGroup();
} else {
result[i].addIgnoredGroup();
}
continue;
}
DataCell cell = row.getCell(testColumnsIndex[i]);
if (!cell.isMissing()) {
DoubleValue value = (DoubleValue) cell;
result[i].addValue(value.getDoubleValue(), group);
} else {
result[i].addMissing(group);
}
}
}
return result;
}
use of org.knime.core.data.DataTableSpec in project knime-core by knime.
the class TwoSampleTTestStatistics method getTTestTable.
/**
* Get the test result of the t-test, for the assumption of equal
* variance and the assumption of unequal variances.
* @param exec the execution context
* @return the t-test results
*/
public BufferedDataTable getTTestTable(final ExecutionContext exec) {
DataTableSpec outSpec = getTableSpec();
BufferedDataContainer cont = exec.createDataContainer(outSpec);
int r = 0;
for (List<DataCell> cells : getTTestCells()) {
cont.addRowToTable(new DefaultRow(RowKey.createRowKey(r), cells));
r++;
}
cont.close();
BufferedDataTable outTable = cont.getTable();
return outTable;
}
Aggregations