Search in sources :

Example 21 with BufferedDataTable

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

the class OneWayANOVAStatistics 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 22 with BufferedDataTable

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

the class OneSampleTTestStatistics 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 23 with BufferedDataTable

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

the class OneSampleTTestStatistics method getDescStatsTable.

/**
 * Get descriptive statistics
 * @param exec
 * @return the descriptive statistics for each column test column
 */
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;
}
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 24 with BufferedDataTable

use of org.knime.core.node.BufferedDataTable 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 25 with BufferedDataTable

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

the class TwoSampleTTestNodeView method renderDescriptiveStatistics.

/**
 * Create HTML for the descriptive statistics.
 */
private String renderDescriptiveStatistics() {
    StringBuilder buffer = NodeViewUtil.createHtmlHeader();
    buffer.append("<body>\n");
    buffer.append("<h3>Group Statistics</h3>");
    NodeViewUtil.renderDataTable(getNodeModel().getDescritiveStatistics(), TwoSampleTTestStatistics.TEST_COLUMN, Arrays.asList(new String[] { TwoSampleTTestStatistics.TEST_COLUMN, TwoSampleTTestStatistics.IGNORED_COUNT_GROUP_COL }), new HashMap<String, String>(), buffer);
    BufferedDataTable descStats = getNodeModel().getDescritiveStatistics();
    if (descStats.getRowCount() > 0) {
        CloseableRowIterator iter = descStats.iteratorFailProve();
        int ignoredIndex = descStats.getSpec().findColumnIndex(TwoSampleTTestStatistics.IGNORED_COUNT_GROUP_COL);
        DataCell ignoredCell = iter.next().getCell(ignoredIndex);
        if (!ignoredCell.isMissing()) {
            int ignoredCount = ((IntValue) ignoredCell).getIntValue();
            if (ignoredCount > 0) {
                buffer.append("<p>");
                buffer.append(ignoredCount);
                buffer.append(ignoredCount > 1 ? " rows have been ignored. Their " : " row has been ignored. Its ");
                buffer.append("value in the grouping column is neither \"");
                buffer.append(getNodeModel().getSettings().getGroupOne());
                buffer.append("\" nor \"");
                buffer.append(getNodeModel().getSettings().getGroupTwo());
                buffer.append("\".");
                buffer.append("</p>");
            }
        }
        iter.close();
    }
    buffer.append("</body>\n");
    buffer.append("</html>\n");
    return buffer.toString();
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) CloseableRowIterator(org.knime.core.data.container.CloseableRowIterator) DataCell(org.knime.core.data.DataCell) IntValue(org.knime.core.data.IntValue)

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