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

📄 classifierpanel.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    });    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());	    } else {	      visualize(null, 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(8, 1));	moreOptionsPanel.add(m_OutputModelBut);	moreOptionsPanel.add(m_OutputPerClassBut);	  	moreOptionsPanel.add(m_OutputEntropyBut);	  	moreOptionsPanel.add(m_OutputConfusionBut);	  	moreOptionsPanel.add(m_StorePredictionsBut);	moreOptionsPanel.add(m_OutputPredictionsTextBut);	JPanel costMatrixOption = new JPanel();	costMatrixOption.setLayout(new BorderLayout());	costMatrixOption.add(m_EvalWRTCostsBut, BorderLayout.WEST);	costMatrixOption.add(m_SetCostsBut, BorderLayout.EAST);	moreOptionsPanel.add(costMatrixOption);	JPanel seedPanel = new JPanel();	seedPanel.setLayout(new BorderLayout());	seedPanel.add(m_RandomLab, BorderLayout.WEST);	seedPanel.add(m_RandomSeedText, BorderLayout.EAST);	moreOptionsPanel.add(seedPanel);	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);      }    });    // 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);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 2;     gbC.gridx = 1;    gbC.insets = new Insets(2, 10, 2, 10);    gbL.setConstraints(m_CVLab, gbC);    p2.add(m_CVLab);    gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.fill = GridBagConstraints.HORIZONTAL;    gbC.gridy = 2;     gbC.gridx = 2;  gbC.weightx = 100;    gbC.ipadx = 20;    gbL.setConstraints(m_CVText, gbC);    p2.add(m_CVText);    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());    m_OutputPredictionsTextBut.setEnabled(m_TestSplitBut.isSelected());    if ((m_SetTestFrame != null) && (!m_TestSplitBut.isSelected())) {      m_SetTestFrame.setVisible(false);    }    m_CVText.setEnabled(m_CVBut.isSelected());    m_CVLab.setEnabled(m_CVBut.isSelected());    m_PercentText.setEnabled(m_PercentBut.isSelected());    m_PercentLab.setEnabled(m_PercentBut.isSelected());  }  /**   * 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   */  public void setInstances(Instances inst) {    m_Instances = inst;    setXY_VisualizeIndexes(0,0); // reset the default x and y indexes    String [] attribNames = new String [m_Instances.numAttributes()];    for (int i = 0; i < attribNames.length; i++) {      String type = "";      switch (m_Instances.attribute(i).type()) {      case Attribute.NOMINAL:	type = "(Nom) ";	break;      case Attribute.NUMERIC:	type = "(Num) ";	break;      case Attribute.STRING:	type = "(Str) ";	break;      default:	type = "(???) ";      }      attribNames[i] = type + m_Instances.attribute(i).name();    }    m_ClassCombo.setModel(new DefaultComboBoxModel(attribNames));    if (attribNames.length > 0) {      m_ClassCombo.setSelectedIndex(attribNames.length - 1);      m_ClassCombo.setEnabled(true);      m_StartBut.setEnabled(m_RunThread == null);      m_StopBut.setEnabled(m_RunThread != null);    } else {      m_StartBut.setEnabled(false);      m_StopBut.setEnabled(false);    }  }  /**   * Sets the user test set. Information about the current test set   * is displayed in an InstanceSummaryPanel and the user is given the   * ability to load another set from a file or url.   *   */  protected void setTestSet() {    if (m_SetTestFrame == null) {      final SetInstancesPanel sp = new SetInstancesPanel();      m_Summary = sp.getSummary();      if (m_TestInstancesCopy != null) {	sp.setInstances(m_TestInstancesCopy);      }      sp.addPropertyChangeListener(new PropertyChangeListener() {	public void propertyChange(PropertyChangeEvent e) {	  m_TestInstances = sp.getInstances();	}      });      // Add propertychangelistener to update m_TestInstances whenever      // it changes in the settestframe      m_SetTestFrame = new JFrame("Test Instances");      m_SetTestFrame.getContentPane().setLayout(new BorderLayout());      m_SetTestFrame.getContentPane().add(sp, BorderLayout.CENTER);      m_SetTestFrame.pack();    }

⌨️ 快捷键说明

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