Search in sources :

Example 16 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable in project knime-core by knime.

the class StringToDateTimeNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    final ColumnRearranger columnRearranger = createColumnRearranger(inData[0].getDataTableSpec());
    final BufferedDataTable out = exec.createColumnRearrangeTable(inData[0], columnRearranger, exec);
    if (m_failCounter > 0) {
        setWarningMessage(m_failCounter + " rows could not be converted. Check the message in the missing cells for details.");
    }
    return new BufferedDataTable[] { out };
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) BufferedDataTable(org.knime.core.node.BufferedDataTable)

Example 17 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable in project knime-core by knime.

the class StringToDurationPeriodNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    final BufferedDataTable in = inData[0];
    if (m_type.getStringValue().equals(OutputType.Automatic.name())) {
        DataTableRowInput rowInput = new DataTableRowInput(in);
        try {
            detectTypes(rowInput);
        } finally {
            rowInput.close();
        }
        // no more rows to look at, guess that column is Period, if it was not detected
        for (int i = 0; i < m_detectedTypes.length; i++) {
            if (m_detectedTypes[i] == null) {
                m_detectedTypes[i] = PeriodCellFactory.TYPE;
            }
        }
    }
    final ColumnRearranger r = createColumnRearranger(in.getDataTableSpec());
    final BufferedDataTable out = exec.createColumnRearrangeTable(in, r, exec);
    if (m_failCounter > 0) {
        setWarningMessage(m_failCounter + " rows could not be converted. Check the message in the missing cells for details.");
    }
    return new BufferedDataTable[] { out };
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput)

Example 18 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable in project knime-core by knime.

the class LeveneTestStatistics 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;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataCell(org.knime.core.data.DataCell) DefaultRow(org.knime.core.data.def.DefaultRow)

Example 19 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable in project knime-core by knime.

the class OneSampleTTestNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    DataTableSpec spec = inData[0].getSpec();
    FilterResult filter = m_settings.getTestColumns().applyTo(spec);
    OneSampleTTest test = new OneSampleTTest(filter.getIncludes(), m_settings.getTestValue(), m_settings.getConfidenceIntervalProb());
    OneSampleTTestStatistics[] result = test.execute(inData[0], exec);
    m_descStats = getDescriptiveStatisticsTable(result, exec);
    m_stats = getTestStatisticsTable(result, exec);
    return new BufferedDataTable[] { m_stats, m_descStats };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) BufferedDataTable(org.knime.core.node.BufferedDataTable) FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult)

Example 20 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable in project knime-core by knime.

the class StandCronbachNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    PMCCPortObjectAndSpec model = (PMCCPortObjectAndSpec) inData[0];
    HalfDoubleMatrix mat = model.getCorrelationMatrix();
    double sum = 0;
    double count = 0;
    for (int i = 0; i < mat.getRowCount(); i++) {
        for (int j = i + 1; j < mat.getRowCount(); j++) {
            if (Double.isNaN(mat.get(i, j))) {
                throw new IOException("No NAN values supported for the calculation, " + "try using an alternative correlation meassure");
            }
            sum += mat.get(i, j);
            count++;
        }
    }
    double mean = sum / count;
    double cronbach = (mat.getRowCount() * mean) / (1 + (mat.getRowCount() - 1) * mean);
    BufferedDataContainer out = exec.createDataContainer(getDataTableSpec());
    RowKey k = new RowKey("Cronbach");
    DataRow r = new DefaultRow(k, new DoubleCell(cronbach));
    out.addRowToTable(r);
    out.close();
    return new BufferedDataTable[] { out.getTable() };
}
Also used : PMCCPortObjectAndSpec(org.knime.base.node.preproc.correlation.pmcc.PMCCPortObjectAndSpec) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) RowKey(org.knime.core.data.RowKey) DoubleCell(org.knime.core.data.def.DoubleCell) HalfDoubleMatrix(org.knime.base.util.HalfDoubleMatrix) BufferedDataTable(org.knime.core.node.BufferedDataTable) IOException(java.io.IOException) DefaultRow(org.knime.core.data.def.DefaultRow) DataRow(org.knime.core.data.DataRow)

Aggregations

BufferedDataTable (org.knime.core.node.BufferedDataTable)460 DataTableSpec (org.knime.core.data.DataTableSpec)221 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)148 DataRow (org.knime.core.data.DataRow)130 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)104 PortObject (org.knime.core.node.port.PortObject)102 DataCell (org.knime.core.data.DataCell)93 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)66 DataColumnSpec (org.knime.core.data.DataColumnSpec)65 DefaultRow (org.knime.core.data.def.DefaultRow)63 RowKey (org.knime.core.data.RowKey)59 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)55 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)54 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)50 ExecutionContext (org.knime.core.node.ExecutionContext)47 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)44 IOException (java.io.IOException)43 ArrayList (java.util.ArrayList)37 LinkedHashMap (java.util.LinkedHashMap)31 Test (org.junit.Test)30