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

📄 resultspanel.java

📁 wekaUT是 university texas austin 开发的基于weka的半指导学习(semi supervised learning)的分类器
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* *    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. *//* *    ResultsPanel.java *    Copyright (C) 1999 Len Trigg *    Modified by Prem Melville * */package weka.gui.experiment;import java.util.*;import weka.gui.ExtensionFileFilter;import weka.gui.ListSelectorDialog;import weka.gui.ResultHistoryPanel;import weka.gui.SaveBuffer;import weka.experiment.Experiment;import weka.experiment.InstancesResultListener;import weka.experiment.DatabaseResultListener;import weka.experiment.PairedTTester;import weka.experiment.InstanceQuery;import weka.core.Utils;import weka.core.Attribute;import weka.core.Instances;import weka.core.Range;import weka.core.Instance;//=============== BEGIN EDIT mbilenko ===============import java.io.PrintWriter;import java.io.BufferedOutputStream;import java.io.FileOutputStream;import java.io.FilenameFilter;//=============== END EDIT mbilenko ===============import java.io.Reader;import java.io.FileReader;import java.io.BufferedReader;import java.io.File;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.Font;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JPanel;import javax.swing.JLabel;import javax.swing.JFrame;import javax.swing.JButton;import javax.swing.JTextArea;import javax.swing.BorderFactory;import javax.swing.JScrollPane;import javax.swing.SwingConstants;import javax.swing.filechooser.FileFilter;import javax.swing.JFileChooser;import javax.swing.JComboBox;import javax.swing.JTextField;import javax.swing.DefaultComboBoxModel;import javax.swing.DefaultListModel;import javax.swing.JList;import javax.swing.ListSelectionModel;import javax.swing.JOptionPane;import javax.swing.JCheckBox;import java.awt.GridBagLayout;import java.awt.GridBagConstraints;import java.awt.Insets;import java.util.Date;import java.text.SimpleDateFormat;import java.awt.Dimension;import javax.swing.SwingUtilities;/**  * This panel controls simple analysis of experimental results. * * @author Len Trigg (trigg@cs.waikato.ac.nz) * @version $Revision: 1.12 $ */public class ResultsPanel extends JPanel {  /** Message shown when no experimental results have been loaded */  protected static final String NO_SOURCE = "No source";  /** Click to load results from a file */  protected JButton m_FromFileBut = new JButton("File...");  /** Click to load results from a database */  protected JButton m_FromDBaseBut = new JButton("Database...");  /** Click to get results from the destination given in the experiment */  protected JButton m_FromExpBut = new JButton("Experiment");  /** Displays a message about the current result set */  protected JLabel m_FromLab = new JLabel(NO_SOURCE);  /**   * This is needed to get around a bug in Swing <= 1.1 -- Once everyone   * is using Swing 1.1.1 or higher just remove this variable and use the   * no-arg constructor to DefaultComboBoxModel   */  private static String [] FOR_JFC_1_1_DCBM_BUG = {""};  /** The model embedded in m_DatasetCombo */  protected DefaultComboBoxModel m_DatasetModel =    new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG);    /** The model embedded in m_RunCombo */  protected DefaultComboBoxModel m_RunModel =    new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG);    /** The model embedded in m_CompareCombo */  protected DefaultComboBoxModel m_CompareModel =     new DefaultComboBoxModel(FOR_JFC_1_1_DCBM_BUG);    /** The model embedded in m_TestsList */  protected DefaultListModel m_TestsModel = new DefaultListModel();  /** Displays the currently selected column names for the scheme & options */  protected JLabel m_DatasetKeyLabel = new JLabel("Row key fields",						 SwingConstants.RIGHT);  /** Click to edit the columns used to determine the scheme */  protected JButton m_DatasetKeyBut = new JButton("Select keys...");  /** Stores the list of attributes for selecting the scheme columns */  protected DefaultListModel m_DatasetKeyModel = new DefaultListModel();  /** Displays the list of selected columns determining the scheme */  protected JList m_DatasetKeyList = new JList(m_DatasetKeyModel);  /** Lets the user select which column contains the run number */  protected JComboBox m_RunCombo = new JComboBox(m_RunModel);  /** Displays the currently selected column names for the scheme & options */  protected JLabel m_ResultKeyLabel = new JLabel("Column key fields",						 SwingConstants.RIGHT);  /** Click to edit the columns used to determine the scheme */  protected JButton m_ResultKeyBut = new JButton("Select keys...");  /** Stores the list of attributes for selecting the scheme columns */  protected DefaultListModel m_ResultKeyModel = new DefaultListModel();  /** Displays the list of selected columns determining the scheme */  protected JList m_ResultKeyList = new JList(m_ResultKeyModel);  /** Lets the user select which scheme to base comparisons against */  protected JButton m_TestsButton = new JButton("Select base...");  /** Holds the list of schemes to base the test against */  protected JList m_TestsList = new JList(m_TestsModel);  /** Lets the user select which performance measure to analyze */  protected JComboBox m_CompareCombo = new JComboBox(m_CompareModel);  /** Lets the user edit the test significance */  protected JTextField m_SigTex = new JTextField("0.05");  /** Lets the user select whether standard deviations are to be output      or not */  protected JCheckBox m_ShowStdDevs =     new JCheckBox("");  /** Click to start the test */  protected JButton m_PerformBut = new JButton("Perform test");    /** Click to save test output to a file */  protected JButton m_SaveOutBut = new JButton("Save output");  //=============== BEGIN EDIT mbilenko ===============  /** Click to launch gnuplot */  protected JButton m_PlotBut = new JButton("Plot");  //=============== END EDIT mbilenko ===============      //=============== BEGIN EDIT melville ===============    /** Lets the user specify the precision of results desired */    protected JTextField m_PrecTex = new JTextField("2");    //To remember index of error for computing error reductions    protected int m_ErrorCompareCol;    //=============== END EDIT melville ===============    /** The buffer saving object for saving output */  SaveBuffer m_SaveOut = new SaveBuffer(null, this);  /** Displays the output of tests */  protected JTextArea m_OutText = new JTextArea();  /** A panel controlling results viewing */  protected ResultHistoryPanel m_History = new ResultHistoryPanel(m_OutText);  /** Filter to ensure only arff files are selected for result files */    protected FileFilter m_ArffFilter =    new ExtensionFileFilter(Instances.FILE_EXTENSION, "Arff data files");    /** The file chooser for selecting result files */  protected JFileChooser m_FileChooser = new JFileChooser(new File(System.getProperty("user.dir")));  /** The PairedTTester object */  protected PairedTTester m_TTester = new PairedTTester();    /** The instances we're extracting results from */  protected Instances m_Instances;  /** Does any database querying for us */  protected InstanceQuery m_InstanceQuery;  /** A thread to load results instances from a file or database */  protected Thread m_LoadThread;    /** An experiment (used for identifying a result source) -- optional */  protected Experiment m_Exp;  /** An actionlisteners that updates ttest settings */  protected ActionListener m_ConfigureListener = new ActionListener() {    public void actionPerformed(ActionEvent e) {      m_TTester.setRunColumn(m_RunCombo.getSelectedIndex());      setTTester();    }  };    private Dimension COMBO_SIZE = new Dimension(150, m_ResultKeyBut					       .getPreferredSize().height);  /**   * Creates the results panel with no initial experiment.   */  public ResultsPanel() {    // Create/Configure/Connect components    m_FileChooser.setFileFilter(m_ArffFilter);    m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);    m_FromExpBut.setEnabled(false);    m_FromExpBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	if (m_LoadThread == null) {	  m_LoadThread = new Thread() {	    public void run() {	      setInstancesFromExp(m_Exp);	      m_LoadThread = null;	    }	  };	  m_LoadThread.start();	}      }    });    m_FromDBaseBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	if (m_LoadThread == null) {	  m_LoadThread = new Thread() {	    public void run() {	      setInstancesFromDBaseQuery();	    m_LoadThread = null;	    }	  };	  m_LoadThread.start();	}      }    });    m_FromFileBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	int returnVal = m_FileChooser.showOpenDialog(ResultsPanel.this);	if (returnVal == JFileChooser.APPROVE_OPTION) {	  final File selected = m_FileChooser.getSelectedFile();	  if (m_LoadThread == null) {	    m_LoadThread = new Thread() {	      public void run() {		setInstancesFromFile(selected);		m_LoadThread = null;	      }	    };	    m_LoadThread.start();	  }	}      }    });    setComboSizes();    m_DatasetKeyBut.setEnabled(false);    m_DatasetKeyBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	setDatasetKeyFromDialog();      }    });    m_DatasetKeyList.setSelectionMode(ListSelectionModel				      .MULTIPLE_INTERVAL_SELECTION);    m_RunCombo.setEnabled(false);    m_RunCombo.addActionListener(m_ConfigureListener);    m_ResultKeyBut.setEnabled(false);    m_ResultKeyBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	setResultKeyFromDialog();      }    });    m_ResultKeyList.setSelectionMode(ListSelectionModel				     .MULTIPLE_INTERVAL_SELECTION);    m_CompareCombo.setEnabled(false);    m_SigTex.setEnabled(false);    m_PrecTex.setEnabled(false);    //=============== BEGIN EDIT melville ===============    m_TestsButton.setEnabled(false);    //=============== END EDIT melville ===============    m_TestsButton.addActionListener(new ActionListener() {	public void actionPerformed(ActionEvent e) {	  setTestBaseFromDialog();	}      });    m_PerformBut.setEnabled(false);    m_PerformBut.addActionListener(new ActionListener() {      public void actionPerformed(ActionEvent e) {	performTest();	m_SaveOutBut.setEnabled(true);	//=============== BEGIN EDIT mbilenko ===============	m_PlotBut.setEnabled(true);	//=============== END EDIT mbilenko ===============      }    });    m_SaveOutBut.setEnabled(false);    m_SaveOutBut.addActionListener(new ActionListener() {	public void actionPerformed(ActionEvent e) {	  saveBuffer();	}      });    //=============== BEGIN EDIT mbilenko ===============    m_PlotBut.setEnabled(false);    m_PlotBut.addActionListener(new ActionListener() {	public void actionPerformed(ActionEvent e) {	  plotOutput();	}      });    //=============== END EDIT mbilenko ===============	        m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12));    m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    m_OutText.setEditable(false);    m_History.setBorder(BorderFactory.createTitledBorder("Result list"));    // Set up the GUI layout    JPanel p1 = new JPanel();    p1.setBorder(BorderFactory.createTitledBorder("Source"));    JPanel p2 = new JPanel();    GridBagLayout gb = new GridBagLayout();    GridBagConstraints constraints = new GridBagConstraints();    p2.setBorder(BorderFactory.createEmptyBorder(5, 5, 10, 5));    //    p2.setLayout(new GridLayout(1, 3));    p2.setLayout(gb);    constraints.gridx=0;constraints.gridy=0;constraints.weightx=5;    constraints.fill = GridBagConstraints.HORIZONTAL;    constraints.gridwidth=1;constraints.gridheight=1;    constraints.insets = new Insets(0,2,0,2);    p2.add(m_FromFileBut,constraints);    constraints.gridx=1;constraints.gridy=0;constraints.weightx=5;    constraints.gridwidth=1;constraints.gridheight=1;    p2.add(m_FromDBaseBut,constraints);    constraints.gridx=2;constraints.gridy=0;constraints.weightx=5;    constraints.gridwidth=1;constraints.gridheight=1;    p2.add(m_FromExpBut,constraints);    p1.setLayout(new BorderLayout());    p1.add(m_FromLab, BorderLayout.CENTER);    p1.add(p2, BorderLayout.EAST);    JPanel p3 = new JPanel();    p3.setBorder(BorderFactory.createTitledBorder("Configure test"));    GridBagLayout gbL = new GridBagLayout();    p3.setLayout(gbL);    GridBagConstraints gbC = new GridBagConstraints();    gbC.anchor = GridBagConstraints.EAST;    gbC.gridy = 0;     gbC.gridx = 0;    gbC.insets = new Insets(2, 10, 2, 10);    gbL.setConstraints(m_DatasetKeyLabel,gbC);    p3.add(m_DatasetKeyLabel);    gbC = new GridBagConstraints();    gbC.gridy = 0;     gbC.gridx = 1;  gbC.weightx = 100;    gbC.insets = new Insets(5,0,5,0);    gbL.setConstraints(m_DatasetKeyBut, gbC);    p3.add(m_DatasetKeyBut);

⌨️ 快捷键说明

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