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

📄 classifiercustomizer.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 JAVA
字号:
/* *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *    ClassifierCustomizer.java *    Copyright (C) 2002 Mark Hall * */package weka.gui.beans;import weka.core.Utils;import weka.core.OptionHandler;import java.beans.*;import java.awt.BorderLayout;import java.awt.event.*;import javax.swing.JPanel;import javax.swing.JCheckBox;import weka.gui.GenericObjectEditor;import weka.gui.PropertyPanel;import weka.classifiers.Classifier;/** * GUI customizer for the classifier wrapper bean * * @author <a href="mailto:mhall@cs.waikato.ac.nz">Mark Hall</a> * @version $Revision: 1.1.1.1 $ */public class ClassifierCustomizer extends JPanel  implements Customizer {  static {    java.beans.PropertyEditorManager      .registerEditor(weka.core.SelectedTag.class,		      weka.gui.SelectedTagEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.filters.Filter.class,		      weka.gui.GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.attributeSelection.ASSearch.class,		      weka.gui.GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.attributeSelection.ASEvaluation.class,		      weka.gui.GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.Classifier [].class,		      weka.gui.GenericArrayEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.Classifier.class,		      weka.gui.GenericObjectEditor.class);    java.beans.PropertyEditorManager      .registerEditor(weka.classifiers.CostMatrix.class,		      weka.gui.CostMatrixEditor.class);  }  private PropertyChangeSupport m_pcSupport =     new PropertyChangeSupport(this);    private weka.gui.beans.Classifier m_dsClassifier;  private GenericObjectEditor m_ClassifierEditor =     new GenericObjectEditor(true);  private JPanel m_incrementalPanel = new JPanel();  private JCheckBox m_updateIncrementalClassifier     = new JCheckBox("Update classifier on incoming instance stream");  private boolean m_panelVisible = false;  public ClassifierCustomizer() {    try {      m_ClassifierEditor.	setClassType(Classifier.class);            m_ClassifierEditor.setValue(new weka.classifiers.bayes.NaiveBayes());      m_ClassifierEditor.addPropertyChangeListener(new PropertyChangeListener() {	  public void propertyChange(PropertyChangeEvent e) {	    repaint();	    if (m_dsClassifier != null) {	      Classifier editedC = (Classifier)m_ClassifierEditor.getValue();	      m_dsClassifier.setClassifier(editedC);	      // should pass on the property change to any other interested	      // listeners	      //	      System.err.println("--> "+Utils.joinOptions(((OptionHandler)editedC).getOptions()));	      //	      System.err.println("Setting classifier in weka.gui.Classifier");	      checkOnClassifierType();	    }	  }	});      //      System.out.println("Here");      repaint();    } catch (Exception ex) {      ex.printStackTrace();    }    m_updateIncrementalClassifier.      setToolTipText("Train the classifier on "		     +"each individual incoming streamed instance.");    m_updateIncrementalClassifier.      addActionListener(new ActionListener() {	  public void actionPerformed(ActionEvent e) {	    if (m_dsClassifier != null) {	      m_dsClassifier.		setUpdateIncrementalClassifier(m_updateIncrementalClassifier.					       isSelected());	    }	  }	});    m_incrementalPanel.add(m_updateIncrementalClassifier);    setLayout(new BorderLayout());    add(m_ClassifierEditor.getCustomEditor(), BorderLayout.CENTER);    checkOnClassifierType();  }    private void checkOnClassifierType() {    Classifier editedC = (Classifier)m_ClassifierEditor.getValue();    if (editedC instanceof weka.classifiers.UpdateableClassifier) {      if (!m_panelVisible) {	add(m_incrementalPanel, BorderLayout.SOUTH);	m_panelVisible = true;      }    } else {      if (m_panelVisible) {	remove(m_incrementalPanel);	m_panelVisible = false;      }    }  }  /**   * Set the classifier object to be edited   *   * @param object an <code>Object</code> value   */  public void setObject(Object object) {    m_dsClassifier = (weka.gui.beans.Classifier)object;    //    System.err.println(Utils.joinOptions(((OptionHandler)m_dsClassifier.getClassifier()).getOptions()));    m_ClassifierEditor.setValue(m_dsClassifier.getClassifier());    //    m_ClassifierEditor.setValue(m_dsClassifier.getClassifier());    m_updateIncrementalClassifier.      setSelected(m_dsClassifier.getUpdateIncrementalClassifier());    checkOnClassifierType();  }  /**   * Add a property change listener   *   * @param pcl a <code>PropertyChangeListener</code> value   */  public void addPropertyChangeListener(PropertyChangeListener pcl) {    m_pcSupport.addPropertyChangeListener(pcl);  }  /**   * Remove a property change listener   *   * @param pcl a <code>PropertyChangeListener</code> value   */  public void removePropertyChangeListener(PropertyChangeListener pcl) {    m_pcSupport.removePropertyChangeListener(pcl);  }}

⌨️ 快捷键说明

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