Search in sources :

Example 1 with BinNaming

use of org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.BinNaming in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method saveSettingsTo.

/**
 * @param settings write intervals to
 * @throws InvalidSettingsException if a bin name is empty
 * @see NodeDialogPane#saveSettingsTo(NodeSettingsWO)
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    m_settings.setTargetColumn(m_targetCol.getIncludedColumnSet().toArray(new String[0]));
    m_settings.setIncludeAll(m_targetCol.isKeepAllSelected());
    Method method = m_methodFixedNumber.isSelected() ? Method.fixedNumber : Method.sampleQuantiles;
    m_settings.setMethod(method);
    m_settings.setBinCount(((Number) m_numBins.getValue()).intValue());
    m_settings.setEqualityMethod((EqualityMethod) m_equalityMethod.getSelectedItem());
    try {
        List<Double> sampleQuantiles = explode(m_sampleQuantiles.getText());
        double[] sq = normalizeSampleQuantiles(sampleQuantiles);
        m_settings.setSampleQuantiles(sq);
    } catch (NumberFormatException e) {
        throw new InvalidSettingsException("Cannot parse the list of quantiles. Changes are " + "not applied.");
    }
    BinNaming binNaming = null;
    if (m_binNamingNumbered.isSelected()) {
        binNaming = BinNaming.numbered;
    }
    if (m_binNamingEdges.isSelected()) {
        binNaming = BinNaming.edges;
    }
    if (m_binNamingMidpoints.isSelected()) {
        binNaming = BinNaming.midpoints;
    }
    m_settings.setBinNaming(binNaming);
    m_settings.setReplaceColumn(m_replaceColumn.isSelected());
    m_settings.setIntegerBounds(m_integerBounds.isSelected());
    m_settings.setAdvancedFormatting(m_advancedFormatting.isSelected());
    m_settings.setOutputFormat((OutputFormat) m_outputFormat.getSelectedItem());
    m_settings.setPrecision(((Number) m_precision.getValue()).intValue());
    m_settings.setPrecisionMode((PrecisionMode) m_precisionMode.getSelectedItem());
    m_settings.setRoundingMode((RoundingMode) m_roundingMode.getSelectedItem());
    m_settings.saveSettings(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Method(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.Method) EqualityMethod(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod) BinNaming(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.BinNaming)

Example 2 with BinNaming

use of org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.BinNaming in project knime-core by knime.

the class AutoBinnerLearnNodeDialogPane method saveSettingsTo.

/**
 * @param settings write intervals to
 * @throws InvalidSettingsException if a bin name is empty
 * @see NodeDialogPane#saveSettingsTo(NodeSettingsWO)
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    DataColumnSpecFilterConfiguration config = AutoBinnerLearnNodeModel.createDCSFilterConfiguration();
    m_filterPanel.saveConfiguration(config);
    m_settings.setFilterConfiguration(config);
    Method method = m_methodFixedNumber.isSelected() ? Method.fixedNumber : Method.sampleQuantiles;
    m_settings.setMethod(method);
    m_settings.setBinCount(((Number) m_numBins.getValue()).intValue());
    m_settings.setEqualityMethod((EqualityMethod) m_equalityMethod.getSelectedItem());
    try {
        List<Double> sampleQuantiles = explode(m_sampleQuantiles.getText());
        double[] sq = normalizeSampleQuantiles(sampleQuantiles);
        m_settings.setSampleQuantiles(sq);
    } catch (NumberFormatException e) {
        throw new InvalidSettingsException("Cannot parse the list of quantiles. Changes are " + "not applied.");
    }
    BinNaming binNaming = null;
    if (m_binNamingNumbered.isSelected()) {
        binNaming = BinNaming.numbered;
    }
    if (m_binNamingEdges.isSelected()) {
        binNaming = BinNaming.edges;
    }
    if (m_binNamingMidpoints.isSelected()) {
        binNaming = BinNaming.midpoints;
    }
    m_settings.setBinNaming(binNaming);
    m_settings.setReplaceColumn(m_replaceColumn.isSelected());
    m_settings.setIntegerBounds(m_integerBounds.isSelected());
    m_settings.setAdvancedFormatting(m_advancedFormatting.isSelected());
    m_settings.setOutputFormat((OutputFormat) m_outputFormat.getSelectedItem());
    m_settings.setPrecision(((Number) m_precision.getValue()).intValue());
    m_settings.setPrecisionMode((PrecisionMode) m_precisionMode.getSelectedItem());
    m_settings.setRoundingMode((RoundingMode) m_roundingMode.getSelectedItem());
    m_settings.saveSettings(settings);
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) EqualityMethod(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod) Method(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method) BinNaming(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)

Aggregations

InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 BinNaming (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.BinNaming)1 EqualityMethod (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod)1 Method (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.Method)1 BinNaming (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)1 EqualityMethod (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod)1 Method (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method)1 DataColumnSpecFilterConfiguration (org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)1