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

📄 miresultspanel.java

📁 MILK 提供了一个实现和比较multi-instance学习算法的环境
💻 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 * */package milk.gui.experiment;import weka.gui.ExtensionFileFilter;import weka.gui.ListSelectorDialog;import weka.gui.ResultHistoryPanel;import weka.gui.SaveBuffer;import milk.experiment.MIExperiment;import milk.experiment.MIInstancesResultListener;import milk.experiment.MIDatabaseResultListener;import weka.experiment.PairedCorrectedTTester;import weka.experiment.PairedTTester;import milk.experiment.MIInstanceQuery;import weka.core.Utils;import weka.core.Attribute;import weka.core.Instances;import weka.core.Range;import weka.core.Instance;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.JSplitPane;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.25 $ */public class MIResultsPanel 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");  /** 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 PairedCorrectedTTester();    /** The instances we're extracting results from */  protected Instances m_Instances;  /** Does any database querying for us */  protected MIInstanceQuery 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 MIExperiment 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 MIResultsPanel() {    // 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(MIResultsPanel.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_TestsButton.setEnabled(false);    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);      }    });    m_PerformBut.setToolTipText("Performs test using corrected resampled t-test statistic (Nadeau and Bengio)");    m_SaveOutBut.setEnabled(false);    m_SaveOutBut.addActionListener(new ActionListener() {	public void actionPerformed(ActionEvent e) {	  saveBuffer();	}      });    m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12));    m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));    m_OutText.setEditable(false);

⌨️ 快捷键说明

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