Search in sources :

Example 1 with EqualityMethod

use of org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod 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 EqualityMethod

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

the class AutoBinnerLearnNodeDialogPane method createMethodUIControls.

private JPanel createMethodUIControls() {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 0;
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodFixedNumber = new JRadioButton("Fixed number of bins");
    m_methodFixedNumber.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(m_methodFixedNumber.isSelected());
            m_equalityMethod.setEnabled(m_methodFixedNumber.isSelected());
            m_sampleQuantiles.setEnabled(!m_methodFixedNumber.isSelected());
        }
    });
    p.add(m_methodFixedNumber, c);
    c.gridy++;
    // JPanel numBinsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    JPanel numBinsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    numBinsPanel.add(new JLabel("Number of bins:"), gbc);
    gbc.gridx++;
    m_numBins = new JSpinner(new SpinnerNumberModel(5, 1, Integer.MAX_VALUE, 1));
    numBinsPanel.add(m_numBins, gbc);
    gbc.weightx = 1;
    gbc.gridx++;
    numBinsPanel.add(new JLabel(), gbc);
    gbc.weightx = 0;
    gbc.gridx = 0;
    gbc.gridy++;
    numBinsPanel.add(new JLabel("Equal:"), gbc);
    gbc.gridx++;
    m_equalityMethod = new JComboBox<EqualityMethod>(EqualityMethod.values());
    numBinsPanel.add(m_equalityMethod, gbc);
    numBinsPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    p.add(numBinsPanel, c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodSampleQuantiles = new JRadioButton("Sample quantiles");
    m_methodSampleQuantiles.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_equalityMethod.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_sampleQuantiles.setEnabled(m_methodSampleQuantiles.isSelected());
        }
    });
    p.add(m_methodSampleQuantiles, c);
    c.gridy++;
    JPanel quantilesPanel = new JPanel(new GridBagLayout());
    int gridy = c.gridy;
    c.gridy = 0;
    c.gridwidth = 1;
    quantilesPanel.add(new JLabel("Quantiles (comma separated):"), c);
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 1;
    m_sampleQuantiles = new JTextField();
    quantilesPanel.add(m_sampleQuantiles, c);
    quantilesPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    c.gridy = gridy;
    c.gridx = 0;
    c.gridwidth = 1;
    p.add(quantilesPanel, c);
    ButtonGroup method = new ButtonGroup();
    method.add(m_methodFixedNumber);
    method.add(m_methodSampleQuantiles);
    p.setBorder(BorderFactory.createTitledBorder("Binning Method"));
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) EqualityMethod(org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod)

Example 3 with EqualityMethod

use of org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod 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)

Example 4 with EqualityMethod

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

the class AutoBinnerLearnNodeDialogPane method createMethodUIControls.

private JPanel createMethodUIControls(final boolean supportsQuantile) {
    JPanel p = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);
    c.weightx = 0;
    c.gridy = 0;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodFixedNumber = new JRadioButton("Fixed number of bins");
    m_methodFixedNumber.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(m_methodFixedNumber.isSelected());
            m_equalityMethod.setEnabled(m_methodFixedNumber.isSelected());
            m_sampleQuantiles.setEnabled(!m_methodFixedNumber.isSelected());
        }
    });
    if (supportsQuantile) {
        p.add(m_methodFixedNumber, c);
    }
    c.gridy++;
    // JPanel numBinsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    JPanel numBinsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    numBinsPanel.add(new JLabel("Number of bins:"), gbc);
    gbc.gridx++;
    m_numBins = new JSpinner(new SpinnerNumberModel(5, 1, Integer.MAX_VALUE, 1));
    numBinsPanel.add(m_numBins, gbc);
    m_equalityMethod = new JComboBox<EqualityMethod>(EqualityMethod.values());
    if (supportsQuantile) {
        gbc.weightx = 1;
        gbc.gridx++;
        numBinsPanel.add(new JLabel(), gbc);
        gbc.weightx = 0;
        gbc.gridx = 0;
        gbc.gridy++;
        numBinsPanel.add(new JLabel("Equal:"), gbc);
        gbc.gridx++;
        numBinsPanel.add(m_equalityMethod, gbc);
        numBinsPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    }
    p.add(numBinsPanel, c);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    m_methodSampleQuantiles = new JRadioButton("Sample quantiles");
    m_methodSampleQuantiles.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            m_numBins.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_equalityMethod.setEnabled(!m_methodSampleQuantiles.isSelected());
            m_sampleQuantiles.setEnabled(m_methodSampleQuantiles.isSelected());
        }
    });
    if (supportsQuantile) {
        p.add(m_methodSampleQuantiles, c);
    }
    c.gridy++;
    JPanel quantilesPanel = new JPanel(new GridBagLayout());
    int gridy = c.gridy;
    c.gridy = 0;
    c.gridwidth = 1;
    quantilesPanel.add(new JLabel("Quantiles (comma separated):"), c);
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 1;
    m_sampleQuantiles = new JTextField();
    quantilesPanel.add(m_sampleQuantiles, c);
    quantilesPanel.setBorder(BorderFactory.createEmptyBorder(0, 17, 0, 0));
    c.gridy = gridy;
    c.gridx = 0;
    c.gridwidth = 1;
    if (supportsQuantile) {
        p.add(quantilesPanel, c);
    }
    ButtonGroup method = new ButtonGroup();
    method.add(m_methodFixedNumber);
    method.add(m_methodSampleQuantiles);
    if (supportsQuantile) {
        p.setBorder(BorderFactory.createTitledBorder("Binning Method"));
    }
    return p;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) EqualityMethod(org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod)

Aggregations

GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ButtonGroup (javax.swing.ButtonGroup)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JRadioButton (javax.swing.JRadioButton)2 JSpinner (javax.swing.JSpinner)2 JTextField (javax.swing.JTextField)2 SpinnerNumberModel (javax.swing.SpinnerNumberModel)2 EqualityMethod (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.EqualityMethod)2 EqualityMethod (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 BinNaming (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.BinNaming)1 Method (org.knime.base.node.preproc.autobinner2.AutoBinnerLearnSettings.Method)1 BinNaming (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)1 Method (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method)1 DataColumnSpecFilterConfiguration (org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)1