Search in sources :

Example 41 with DataTableSpec

use of org.knime.core.data.DataTableSpec in project knime-core by knime.

the class OneWayANOVANodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    DataTableSpec spec = specs[0];
    m_settings.loadSettingsForDialog(settings, spec);
    m_testColumns.loadConfiguration(m_settings.getTestColumns(), spec);
    m_groupingColumn.update(spec, m_settings.getGroupingColumn());
    m_confidenceIntervalProb.setText(Double.toString(m_settings.getConfidenceIntervalProb() * 100.0));
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec)

Example 42 with DataTableSpec

use of org.knime.core.data.DataTableSpec in project knime-core by knime.

the class OneWayANOVANodeModel method configure.

/**
 * {@inheritDoc}
 */
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
    DataTableSpec spec = inSpecs[0];
    if (m_settings.getGroupingColumn() == null || !spec.containsName(m_settings.getGroupingColumn())) {
        throw new InvalidSettingsException("Please define a grouping column.");
    }
    FilterResult filterResult = m_settings.getTestColumns().applyTo(spec);
    if (filterResult.getIncludes().length == 0) {
        if (filterResult.getExcludes().length > 0) {
            throw new InvalidSettingsException("Please select at least " + "one test column.");
        } else {
            throw new InvalidSettingsException("There are no numeric columns " + "in the input table. At least one numeric column " + "is needed to perform the test.");
        }
    }
    if (m_settings.getConfidenceIntervalProb() > 0.99 || m_settings.getConfidenceIntervalProb() < 0.01) {
        throw new InvalidSettingsException("The property " + "\"Confidence Interval (in %)\" must be in the range " + "[1, 99].");
    }
    return new DataTableSpec[] { OneWayANOVAStatistics.getTableSpec(), LeveneTestStatistics.getTableSpec(), OneWayANOVAStatistics.getGroupStatisticsSpec() };
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult)

Example 43 with DataTableSpec

use of org.knime.core.data.DataTableSpec in project knime-core by knime.

the class OneWayANOVANodeModel method getGroups.

private List<String> getGroups(final BufferedDataTable inData, final ExecutionMonitor exec) throws InvalidSettingsException, CanceledExecutionException {
    DataTableSpec spec = inData.getSpec();
    int gIndex = spec.findColumnIndex(m_settings.getGroupingColumn());
    LinkedHashSet<String> groups = new LinkedHashSet<String>();
    if (gIndex < 0) {
        throw new InvalidSettingsException("Grouping column not found.");
    }
    final int rowCount = inData.getRowCount();
    int rowIndex = 0;
    for (DataRow row : inData) {
        exec.checkCanceled();
        exec.setProgress(rowIndex++ / (double) rowCount, rowIndex + "/" + rowCount + " (\"" + row.getKey() + "\")");
        DataCell group = row.getCell(gIndex);
        if (!group.isMissing()) {
            groups.add(group.toString());
        }
    }
    return Arrays.asList(groups.toArray(new String[groups.size()]));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DataCell(org.knime.core.data.DataCell) DataRow(org.knime.core.data.DataRow)

Example 44 with DataTableSpec

use of org.knime.core.data.DataTableSpec 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 45 with DataTableSpec

use of org.knime.core.data.DataTableSpec in project knime-core by knime.

the class OneSampleTTestNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    DataTableSpec spec = specs[0];
    m_settings.loadSettingsForDialog(settings, spec);
    m_testColumns.loadConfiguration(m_settings.getTestColumns(), spec);
    m_testValue.setText(Double.toString(m_settings.getTestValue()));
    m_confidenceIntervalProb.setText(Double.toString(m_settings.getConfidenceIntervalProb() * 100.0));
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec)

Aggregations

DataTableSpec (org.knime.core.data.DataTableSpec)938 DataColumnSpec (org.knime.core.data.DataColumnSpec)340 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)306 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)228 BufferedDataTable (org.knime.core.node.BufferedDataTable)226 DataCell (org.knime.core.data.DataCell)186 DataRow (org.knime.core.data.DataRow)170 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)136 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)129 DataType (org.knime.core.data.DataType)109 ArrayList (java.util.ArrayList)106 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)98 DoubleValue (org.knime.core.data.DoubleValue)94 DefaultRow (org.knime.core.data.def.DefaultRow)92 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)90 ExecutionContext (org.knime.core.node.ExecutionContext)68 PortObject (org.knime.core.node.port.PortObject)66 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)62 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)61 RowKey (org.knime.core.data.RowKey)59