Search in sources :

Example 1 with OperatorColumnSettings

use of org.knime.base.data.aggregation.OperatorColumnSettings in project knime-core by knime.

the class NumericOutliersIntervalsCalculator method getAggretators.

/**
 * Creates column aggregators for each of the outlier columns.
 *
 * @param inSpec the input data table spec
 * @param gSettings the global settings
 * @return an array of column aggregators
 */
private ColumnAggregator[] getAggretators(final DataTableSpec inSpec, final GlobalSettings gSettings) {
    final ColumnAggregator[] aggregators = new ColumnAggregator[m_outlierColNames.length * 2];
    int pos = 0;
    // for each outlier column name create the aggregators
    for (final String outlierColName : m_outlierColNames) {
        // the operator column settings
        final OperatorColumnSettings cSettings = new OperatorColumnSettings(INCL_MISSING_CELLS, inSpec.getColumnSpec(outlierColName));
        // setting
        for (final double percentile : PERCENTILES) {
            final AggregationMethod method;
            if (m_useHeuristic) {
                method = new PSquarePercentileOperator(gSettings, cSettings, 100 * percentile);
            } else {
                method = new QuantileOperator(new OperatorData("Quantile", true, false, DoubleValue.class, INCL_MISSING_CELLS), gSettings, cSettings, percentile, m_estimationType.name());
            }
            aggregators[pos++] = new ColumnAggregator(cSettings.getOriginalColSpec(), method);
        }
    }
    // return the aggregators
    return aggregators;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) PSquarePercentileOperator(org.knime.base.data.aggregation.numerical.PSquarePercentileOperator) QuantileOperator(org.knime.base.data.aggregation.numerical.QuantileOperator) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) OperatorColumnSettings(org.knime.base.data.aggregation.OperatorColumnSettings) OperatorData(org.knime.base.data.aggregation.OperatorData)

Example 2 with OperatorColumnSettings

use of org.knime.base.data.aggregation.OperatorColumnSettings in project knime-core by knime.

the class CrosstabNodeModel method createGroupByTable.

/**
 * Create group-by table.
 * @param exec execution context
 * @param table input table to group
 * @param groupByCols column selected for group-by operation
 * @return table with group and aggregation columns
 * @throws CanceledExecutionException if the group-by table generation was
 *         canceled externally
 */
private final GroupByTable createGroupByTable(final ExecutionContext exec, final BufferedDataTable table, final List<String> groupByCols) throws CanceledExecutionException {
    final int maxUniqueVals = Integer.MAX_VALUE;
    final boolean enableHilite = m_settings.getEnableHiliting();
    final boolean retainOrder = false;
    final ColumnNamePolicy colNamePolicy = ColumnNamePolicy.AGGREGATION_METHOD_COLUMN_NAME;
    final GlobalSettings globalSettings = GlobalSettings.builder().setFileStoreFactory(FileStoreFactory.createWorkflowFileStoreFactory(exec)).setGroupColNames(groupByCols).setMaxUniqueValues(maxUniqueVals).setValueDelimiter(GlobalSettings.STANDARD_DELIMITER).setDataTableSpec(table.getDataTableSpec()).setNoOfRows(table.size()).setAggregationContext(AggregationContext.ROW_AGGREGATION).build();
    ColumnAggregator collAggregator = null;
    if (null != m_settings.getWeightColumn()) {
        final String weightColumn = m_settings.getWeightColumn();
        // the column aggregator for the weighting column
        final boolean inclMissing = false;
        final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(weightColumn);
        final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
        collAggregator = new ColumnAggregator(originalColSpec, new NonNegativeSumOperator(globalSettings, opColSettings), inclMissing);
    } else {
        // use any column, does not matter as long as it exists and
        // include missing is true;
        final boolean inclMissing = true;
        final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(groupByCols.get(0));
        final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
        collAggregator = new ColumnAggregator(originalColSpec, new CountOperator(globalSettings, opColSettings), inclMissing);
    }
    final GroupByTable resultTable = new BigGroupByTable(exec, table, groupByCols, new ColumnAggregator[] { collAggregator }, globalSettings, enableHilite, colNamePolicy, retainOrder);
    if (enableHilite) {
        setHiliteMapping(new DefaultHiLiteMapper(resultTable.getHiliteMapping()));
    }
    // check for skipped columns
    final String warningMsg = resultTable.getSkippedGroupsMessage(3, 3);
    if (warningMsg != null) {
        setWarningMessage(warningMsg);
    }
    return resultTable;
}
Also used : OperatorColumnSettings(org.knime.base.data.aggregation.OperatorColumnSettings) GlobalSettings(org.knime.base.data.aggregation.GlobalSettings) ColumnNamePolicy(org.knime.base.node.preproc.groupby.ColumnNamePolicy) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) GroupByTable(org.knime.base.node.preproc.groupby.GroupByTable) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) CountOperator(org.knime.base.data.aggregation.general.CountOperator)

Aggregations

ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)2 OperatorColumnSettings (org.knime.base.data.aggregation.OperatorColumnSettings)2 AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)1 GlobalSettings (org.knime.base.data.aggregation.GlobalSettings)1 OperatorData (org.knime.base.data.aggregation.OperatorData)1 CountOperator (org.knime.base.data.aggregation.general.CountOperator)1 PSquarePercentileOperator (org.knime.base.data.aggregation.numerical.PSquarePercentileOperator)1 QuantileOperator (org.knime.base.data.aggregation.numerical.QuantileOperator)1 BigGroupByTable (org.knime.base.node.preproc.groupby.BigGroupByTable)1 ColumnNamePolicy (org.knime.base.node.preproc.groupby.ColumnNamePolicy)1 GroupByTable (org.knime.base.node.preproc.groupby.GroupByTable)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)1