⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classifierpanel.java

📁 :<<数据挖掘--实用机器学习技术及java实现>>一书的配套源程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    updateRadioLinks();    ButtonGroup bg = new ButtonGroup();    bg.add(m_TrainBut);    bg.add(m_CVBut);    bg.add(m_PercentBut);    bg.add(m_TestSplitBut);    m_TrainBut.addActionListener(m_RadioListener);    m_CVBut.addActionListener(m_RadioListener);    m_PercentBut.addActionListener(m_RadioListener);    m_TestSplitBut.addActionListener(m_RadioListener);    m_SetTestBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        setTestSet();      }    });    m_EvalWRTCostsBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        m_SetCostsBut.setEnabled(m_EvalWRTCostsBut.isSelected());        if ((m_SetCostsFrame != null)            && (!m_EvalWRTCostsBut.isSelected())) {          m_SetCostsFrame.setVisible(false);        }      }    });    m_CostMatrixEditor.setValue(new CostMatrix(1));    m_SetCostsBut.setEnabled(m_EvalWRTCostsBut.isSelected());    m_SetCostsBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        m_SetCostsBut.setEnabled(false);        if (m_SetCostsFrame == null) {          m_SetCostsFrame = new PropertyDialog(m_CostMatrixEditor, 100, 100);          //    pd.setSize(250,150);          m_SetCostsFrame.addWindowListener(new java.awt.event.WindowAdapter()          {            public void windowClosing(java.awt.event.WindowEvent p) {              m_SetCostsBut.setEnabled(m_EvalWRTCostsBut.isSelected());              if ((m_SetCostsFrame != null)                  && (!m_EvalWRTCostsBut.isSelected())) {                m_SetCostsFrame.setVisible(false);              }            }          });        }        m_SetCostsFrame.setVisible(true);      }    });    m_StartBut.setEnabled(false);    m_StopBut.setEnabled(false);    m_StartBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        startClassifier();      }    });    m_StopBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        stopClassifier();      }    });    m_ClassCombo.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        int selected = m_ClassCombo.getSelectedIndex();        if (selected != -1) {          boolean isNominal = m_Instances.attribute(selected).isNominal();          m_OutputPerClassBut.setEnabled(isNominal);          m_OutputConfusionBut.setEnabled(isNominal);        }      }    });    m_History.setHandleRightClicks(false);    // see if we can popup a menu for the selected result    m_History.getList().addMouseListener(new MouseAdapter() {        public void mouseClicked(MouseEvent e) {          if ((e.getModifiers() & InputEvent.BUTTON1_MASK)              == InputEvent.BUTTON1_MASK) {          } else {            int index = m_History.getList().locationToIndex(e.getPoint());            if (index != -1) {              String name = m_History.getNameAtIndex(index);              visualize(name, e.getX(), e.getY());            }          }        }      });    m_MoreOptions.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        m_MoreOptions.setEnabled(false);        JPanel moreOptionsPanel = new JPanel();        moreOptionsPanel.setBorder(                         BorderFactory.createEmptyBorder(0, 5, 5, 5));        moreOptionsPanel.setLayout(new GridLayout(6, 1));        moreOptionsPanel.add(m_OutputModelBut);        moreOptionsPanel.add(m_OutputPerClassBut);        moreOptionsPanel.add(m_OutputEntropyBut);        moreOptionsPanel.add(m_OutputConfusionBut);        moreOptionsPanel.add(m_StorePredictionsBut);        JPanel costMatrixOption = new JPanel();        costMatrixOption.setLayout(new BorderLayout());        costMatrixOption.add(m_EvalWRTCostsBut, BorderLayout.WEST);        costMatrixOption.add(m_SetCostsBut, BorderLayout.EAST);        moreOptionsPanel.add(costMatrixOption);        JPanel all = new JPanel();        all.setLayout(new BorderLayout());        JButton oK = new JButton("OK");        JPanel okP = new JPanel();        okP.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));        okP.setLayout(new GridLayout(1,1,5,5));        okP.add(oK);        all.add(moreOptionsPanel, BorderLayout.CENTER);        all.add(okP, BorderLayout.SOUTH);        final javax.swing.JFrame jf =          new javax.swing.JFrame("Classifier evaluation options");        jf.getContentPane().setLayout(new BorderLayout());        jf.getContentPane().add(all, BorderLayout.CENTER);        jf.addWindowListener(new java.awt.event.WindowAdapter() {          public void windowClosing(java.awt.event.WindowEvent w) {            jf.dispose();            m_MoreOptions.setEnabled(true);          }        });        oK.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent a) {            m_MoreOptions.setEnabled(true);            jf.dispose();          }        });        jf.pack();        jf.setLocation(m_MoreOptions.getLocationOnScreen());        jf.setVisible(true);      }    });    // Added by Sebastian Celis for parallelization    // Register the new buttons with ActionListeners    m_CVSettingsBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {        setCVSettings();      }    });    m_ParallelConfigBut.addActionListener(new ActionListener() {        public void actionPerformed(ActionEvent e) {            configureParallelization();        }    });    // Layout the GUI    JPanel p1 = new JPanel();    p1.setBorder(BorderFactory.createCompoundBorder(                 BorderFactory.createTitledBorder("Classifier"),                 BorderFactory.createEmptyBorder(0, 5, 5, 5)                 ));    p1.setLayout(new BorderLayout());    p1.add(m_CEPanel, BorderLayout.NORTH);    JPanel p2 = new JPanel();    GridBagLayout gbL = new GridBagLayout();    p2.setLayout(gbL);    p2.setBorder(BorderFactory.createCompoundBorder(                 BorderFactory.createTitledBorder("Test options"),                 BorderFactory.createEmptyBorder(0, 5, 5, 5)                 ));    GridBagConstraints gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.WEST;    gbC.gridy = 0;     gbC.gridx = 0;    gbL.setConstraints(m_TrainBut, gbC);    p2.add(m_TrainBut);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.WEST;    gbC.gridy = 1;     gbC.gridx = 0;    gbL.setConstraints(m_TestSplitBut, gbC);    p2.add(m_TestSplitBut);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 1;     gbC.gridx = 1;    gbC.gridwidth = 2;    gbC.insets = new Insets(2, 10, 2, 0);    gbL.setConstraints(m_SetTestBut, gbC);    p2.add(m_SetTestBut);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.WEST;    gbC.gridy = 2;     gbC.gridx = 0;    gbL.setConstraints(m_CVBut, gbC);    p2.add(m_CVBut);    // Added by Sebastian Celis for parallelization    // Adds the "Settings" button for cross validation    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 2;     gbC.gridx = 1;    gbC.gridwidth = 2;    gbC.insets = new Insets(2, 10, 2, 0);    gbL.setConstraints(m_CVSettingsBut, gbC);    p2.add(m_CVSettingsBut);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.WEST;    gbC.gridy = 3;     gbC.gridx = 0;    gbL.setConstraints(m_PercentBut, gbC);    p2.add(m_PercentBut);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 3;     gbC.gridx = 1;    gbC.insets = new Insets(2, 10, 2, 10);    gbL.setConstraints(m_PercentLab, gbC);    p2.add(m_PercentLab);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 3;     gbC.gridx = 2;  gbC.weightx = 100;    gbC.ipadx = 20;    gbL.setConstraints(m_PercentText, gbC);    p2.add(m_PercentText);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.WEST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 4;     gbC.gridx = 0;  gbC.weightx = 100;    gbC.gridwidth = 3;    gbC.insets = new Insets(3, 0, 1, 0);    gbL.setConstraints(m_MoreOptions, gbC);    p2.add(m_MoreOptions);    JPanel buttons = new JPanel();    buttons.setLayout(new GridLayout(2, 2));    buttons.add(m_ClassCombo);    m_ClassCombo.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    JPanel ssButs = new JPanel();    ssButs.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    ssButs.setLayout(new GridLayout(1, 2, 5, 5));    ssButs.add(m_StartBut);    ssButs.add(m_StopBut);    buttons.add(ssButs);    JPanel p3 = new JPanel();    p3.setBorder(BorderFactory.createTitledBorder("Classifier output"));    p3.setLayout(new BorderLayout());    final JScrollPane js = new JScrollPane(m_OutText);    p3.add(js, BorderLayout.CENTER);    js.getViewport().addChangeListener(new ChangeListener() {      private int lastHeight;      public void stateChanged(ChangeEvent e) {        JViewport vp = (JViewport)e.getSource();        int h = vp.getViewSize().height;        if (h != lastHeight) { // i.e. an addition not just a user scrolling          lastHeight = h;          int x = h - vp.getExtentSize().height;          vp.setViewPosition(new Point(0, x));        }      }    });    JPanel mondo = new JPanel();    gbL = new GridBagLayout();    mondo.setLayout(gbL);    gbC = new GridBagConstraints();    //    gbC.anchor = GridBagConstraints.WEST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 0;     gbC.gridx = 0;    gbL.setConstraints(p2, gbC);    mondo.add(p2);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.NORTH;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 1;     gbC.gridx = 0;    gbL.setConstraints(buttons, gbC);    mondo.add(buttons);    gbC = new GridBagConstraints();    //gbC.anchor = GridBagConstraints.NORTH;    gbC.fill = GridBagConstraints.BOTH;    gbC.gridy = 2;     gbC.gridx = 0; gbC.weightx = 0;    gbL.setConstraints(m_History, gbC);    mondo.add(m_History);    gbC = new GridBagConstraints();    gbC.fill = GridBagConstraints.BOTH;    gbC.gridy = 0;     gbC.gridx = 1;    gbC.gridheight = 3;    gbC.weightx = 100; gbC.weighty = 100;    gbL.setConstraints(p3, gbC);    mondo.add(p3);    setLayout(new BorderLayout());    add(p1, BorderLayout.NORTH);    add(mondo, BorderLayout.CENTER);  }  /**   * Updates the enabled status of the input fields and labels.   */  protected void updateRadioLinks() {    m_SetTestBut.setEnabled(m_TestSplitBut.isSelected());    if ((m_SetTestFrame != null) && (!m_TestSplitBut.isSelected())) {      m_SetTestFrame.setVisible(false);    }    // Edited by Sebastian Celis for parallelization    // Enables the cross validation settings button only    // when the cross validation radio button is selected.    m_CVSettingsBut.setEnabled(m_CVBut.isSelected());    m_PercentText.setEnabled(m_PercentBut.isSelected());    m_PercentLab.setEnabled(m_PercentBut.isSelected());  }  /**   * Sets the preprocess panel through which user selected   * filters can be applied to any supplied test data   * @param p the preprocess panel to use   */  public void setPreprocess(PreprocessPanel p) {    m_Preprocess = p;  }  /**   * Sets the Logger to receive informational messages   *   * @param newLog the Logger that will now get info messages   */  public void setLog(Logger newLog) {    m_Log = newLog;  }  /**   * Set the default attributes to use on the x and y axis   * of a new visualization object.   * @param x the index of the attribute to use on the x axis   * @param y the index of the attribute to use on the y axis   */  public void setXY_VisualizeIndexes(int x, int y) {    m_visXIndex = x;    m_visYIndex = y;  }  /**   * Tells the panel to use a new set of instances.   *   * @param inst a set of Instances

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -