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));
}
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));
}
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() };
}
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 };
}
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();
}
};
}
Aggregations