Search in sources :

Example 51 with DataTableSpec

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

the class PairedTTestNodeDialog method loadSettingsFrom.

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

Example 52 with DataTableSpec

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

the class TwoSampleTTestNodeDialog method loadSettingsFrom.

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

Example 53 with DataTableSpec

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

the class TwoSampleTTestNodeModel 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.");
    }
    if (m_settings.getGroupOne() == null) {
        throw new InvalidSettingsException("Value of group one is not set.");
    }
    if (m_settings.getGroupTwo() == null) {
        throw new InvalidSettingsException("Value of group two is not set.");
    }
    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[] { TwoSampleTTestStatistics.getTableSpec(), LeveneTestStatistics.getTableSpec(), TwoSampleTTestStatistics.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 54 with DataTableSpec

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

the class TwoSampleTTestNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    Map<Group, String> groups = new LinkedHashMap<Group, String>();
    groups.put(Group.GroupX, m_settings.getGroupOne());
    groups.put(Group.GroupY, m_settings.getGroupTwo());
    Grouping grouping = new StringValueGrouping(m_settings.getGroupingColumn(), groups);
    DataTableSpec spec = inData[0].getSpec();
    FilterResult filter = m_settings.getTestColumns().applyTo(spec);
    TwoSampleTTest test = new TwoSampleTTest(filter.getIncludes(), grouping, m_settings.getConfidenceIntervalProb());
    TwoSampleTTestStatistics[] result = test.execute(inData[0], exec);
    LeveneTest leveneTest = new LeveneTest(filter.getIncludes(), m_settings.getGroupingColumn(), Arrays.asList(new String[] { m_settings.getGroupOne(), m_settings.getGroupTwo() }), getGroupSummaryStats(result));
    LeveneTestStatistics[] leveneResult = leveneTest.execute(inData[0], exec);
    leveneResult[0].getTTestCells();
    m_descStats = getDescriptiveStatisticsTable(result, exec);
    m_leveneStats = getLeveneStatistices(leveneResult, exec);
    m_stats = getTestStatisticsTable(result, exec);
    return new BufferedDataTable[] { m_stats, m_leveneStats, m_descStats };
}
Also used : Group(org.knime.base.node.stats.testing.ttest.Grouping.Group) DataTableSpec(org.knime.core.data.DataTableSpec) LeveneTest(org.knime.base.node.stats.testing.levene.LeveneTest) LeveneTestStatistics(org.knime.base.node.stats.testing.levene.LeveneTestStatistics) LinkedHashMap(java.util.LinkedHashMap) BufferedDataTable(org.knime.core.node.BufferedDataTable) FilterResult(org.knime.core.node.util.filter.NameFilterConfiguration.FilterResult)

Example 55 with DataTableSpec

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

the class DateTimeToStringNodeModel method createStreamableOperator.

/**
 * {@inheritDoc}
 */
@Override
public StreamableOperator createStreamableOperator(final PartitionInfo partitionInfo, final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
    return new StreamableOperator() {

        @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();
            final String[] includeList = m_colSelect.applyTo(inSpec).getIncludes();
            final int[] includeIndeces = Arrays.stream(m_colSelect.applyTo(inSpec).getIncludes()).mapToInt(s -> inSpec.findColumnIndex(s)).toArray();
            final boolean isReplace = m_isReplaceOrAppend.getStringValue().equals(OPTION_REPLACE);
            DataRow row;
            while ((row = in.poll()) != null) {
                exec.checkCanceled();
                DataCell[] datacells = new DataCell[includeIndeces.length];
                for (int i = 0; i < includeIndeces.length; i++) {
                    if (isReplace) {
                        final DataColumnSpecCreator dataColumnSpecCreator = new DataColumnSpecCreator(includeList[i], StringCell.TYPE);
                        final TimeToStringCellFactory cellFac = new TimeToStringCellFactory(dataColumnSpecCreator.createSpec(), includeIndeces[i]);
                        datacells[i] = cellFac.getCell(row);
                    } else {
                        final DataColumnSpec dataColSpec = new UniqueNameGenerator(inSpec).newColumn(includeList[i] + m_suffix.getStringValue(), StringCell.TYPE);
                        final TimeToStringCellFactory cellFac = new TimeToStringCellFactory(dataColSpec, includeIndeces[i]);
                        datacells[i] = cellFac.getCell(row);
                    }
                }
                if (isReplace) {
                    out.push(new ReplacedColumnsDataRow(row, datacells, includeIndeces));
                } else {
                    out.push(new AppendedColumnRow(row, datacells));
                }
            }
            in.close();
            out.close();
        }
    };
}
Also used : Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) LocalDateValue(org.knime.core.data.time.localdate.LocalDateValue) LocalDateTimeCellFactory(org.knime.core.data.time.localdatetime.LocalDateTimeCellFactory) DataColumnSpec(org.knime.core.data.DataColumnSpec) Locale(java.util.Locale) ChangeListener(javax.swing.event.ChangeListener) ZonedDateTimeValue(org.knime.core.data.time.zoneddatetime.ZonedDateTimeValue) ChangeEvent(javax.swing.event.ChangeEvent) PortInput(org.knime.core.node.streamable.PortInput) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) PartitionInfo(org.knime.core.node.streamable.PartitionInfo) Collection(java.util.Collection) Set(java.util.Set) SettingsModelColumnFilter2(org.knime.core.node.defaultnodesettings.SettingsModelColumnFilter2) NodeModel(org.knime.core.node.NodeModel) LocalDateCell(org.knime.core.data.time.localdate.LocalDateCell) BufferedDataTable(org.knime.core.node.BufferedDataTable) InputPortRole(org.knime.core.node.streamable.InputPortRole) StringHistory(org.knime.core.node.util.StringHistory) LocalDateTimeCell(org.knime.core.data.time.localdatetime.LocalDateTimeCell) RowOutput(org.knime.core.node.streamable.RowOutput) DataTableSpec(org.knime.core.data.DataTableSpec) ZonedDateTimeCell(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCell) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow) LocalTimeValue(org.knime.core.data.time.localtime.LocalTimeValue) ExecutionContext(org.knime.core.node.ExecutionContext) LocaleUtils(org.apache.commons.lang3.LocaleUtils) SingleCellFactory(org.knime.core.data.container.SingleCellFactory) ZonedDateTimeCellFactory(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCellFactory) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) DataCell(org.knime.core.data.DataCell) LinkedHashSet(java.util.LinkedHashSet) LocalDateCellFactory(org.knime.core.data.time.localdate.LocalDateCellFactory) LocalTimeCellFactory(org.knime.core.data.time.localtime.LocalTimeCellFactory) StringCellFactory(org.knime.core.data.def.StringCell.StringCellFactory) RowInput(org.knime.core.node.streamable.RowInput) LocalTimeCell(org.knime.core.data.time.localtime.LocalTimeCell) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) OutputPortRole(org.knime.core.node.streamable.OutputPortRole) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) File(java.io.File) DataRow(org.knime.core.data.DataRow) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) PortOutput(org.knime.core.node.streamable.PortOutput) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) LocalDateTimeValue(org.knime.core.data.time.localdatetime.LocalDateTimeValue) MissingCell(org.knime.core.data.MissingCell) DateTimeFormatter(java.time.format.DateTimeFormatter) ColumnRearranger(org.knime.core.data.container.ColumnRearranger) StringCell(org.knime.core.data.def.StringCell) DataType(org.knime.core.data.DataType) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) StreamableOperator(org.knime.core.node.streamable.StreamableOperator) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) RowInput(org.knime.core.node.streamable.RowInput) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) DataRow(org.knime.core.data.DataRow) UniqueNameGenerator(org.knime.core.util.UniqueNameGenerator) RowOutput(org.knime.core.node.streamable.RowOutput) ExecutionContext(org.knime.core.node.ExecutionContext) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataCell(org.knime.core.data.DataCell) ReplacedColumnsDataRow(org.knime.base.data.replace.ReplacedColumnsDataRow) AppendedColumnRow(org.knime.core.data.append.AppendedColumnRow)

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