/*
* 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.
*/
/*
* ExperimentPanel.java
* Copyright (C) 2007 University of Waikato, Hamilton, New Zealand
*
*/
package wekaexamples.gui.explorer;
import weka.classifiers.Classifier;
import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.Instances;
import weka.core.Range;
import weka.core.Utils;
import weka.core.converters.ArffLoader;
import weka.core.converters.Loader;
import weka.core.converters.XRFFLoader;
import weka.core.converters.ConverterUtils.DataSink;
import weka.experiment.ClassifierSplitEvaluator;
import weka.experiment.CrossValidationResultProducer;
import weka.experiment.Experiment;
import weka.experiment.InstancesResultListener;
import weka.experiment.PairedCorrectedTTester;
import weka.experiment.PairedTTester;
import weka.experiment.PropertyNode;
import weka.experiment.RandomSplitResultProducer;
import weka.experiment.RegressionSplitEvaluator;
import weka.experiment.ResultMatrix;
import weka.experiment.ResultMatrixPlainText;
import weka.experiment.SplitEvaluator;
import weka.gui.GenericObjectEditor;
import weka.gui.Logger;
import weka.gui.PropertyPanel;
import weka.gui.ResultHistoryPanel;
import weka.gui.SaveBuffer;
import weka.gui.SysErrLog;
import weka.gui.TaskLogger;
import weka.gui.explorer.Explorer;
import weka.gui.explorer.ExplorerDefaults;
import weka.gui.explorer.Explorer.CapabilitiesFilterChangeEvent;
import weka.gui.explorer.Explorer.CapabilitiesFilterChangeListener;
import weka.gui.explorer.Explorer.ExplorerPanel;
import weka.gui.explorer.Explorer.LogHandler;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyDescriptor;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JViewport;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
* This panel allows the user to select and configure a classifier, set the
* attribute of the current dataset to be used as the class, and perform an
* Experiment (like in the Experimenter) with this Classifier/Dataset
* combination. The results of the experiment runs are stored in a result
* history so that previous results are accessible. <p/>
*
* Based on the ClassifierPanel code (by Len Trigg, Mark Hall and
* Richard Kirkby).
*
* @author FracPete (fracpete at waikato dot ac dot nz)
* @version $Revision$
*/
public class ExperimentPanel
extends JPanel
implements CapabilitiesFilterChangeListener, ExplorerPanel, LogHandler {
/** for serialization. */
private static final long serialVersionUID = 2078066653508312179L;
/** the parent frame. */
protected Explorer m_Explorer = null;
/** Lets the user configure the classifier. */
protected GenericObjectEditor m_ClassifierEditor = new GenericObjectEditor();
/** The panel showing the current classifier selection. */
protected PropertyPanel m_CEPanel = new PropertyPanel(m_ClassifierEditor);
/** The output area for classification results. */
protected JTextArea m_OutText = new JTextArea(20, 40);
/** The destination for log/status messages. */
protected Logger m_Log = new SysErrLog();
/** The buffer saving object for saving output. */
protected SaveBuffer m_SaveOut = new SaveBuffer(m_Log, this);
/** A panel controlling results viewing. */
protected ResultHistoryPanel m_History = new ResultHistoryPanel(m_OutText);
/** The spinner for the number of runs. */
protected JSpinner m_RunsSpinner = new JSpinner();
/** The type of evaluation: cross-validation or random split. */
protected JComboBox m_EvalCombo = new JComboBox(new String[]{"Cross-validation", "Random split"});
/** The label for either the number of folds or the percentage for the random split. */
protected JLabel m_FoldsPercLabel = new JLabel("Folds");
/** Either the number of folds or the percentage for the random split. */
protected JTextField m_FoldsPercText = new JTextField("10", 10);
/** Lets the user select the class column. */
protected JComboBox m_ClassCombo = new JComboBox();
/** Click to start running the experiment. */
protected JButton m_StartBut = new JButton("Start");
/** Click to stop a running experiment. */
protected JButton m_StopBut = new JButton("Stop");
/** Stop the class combo from taking up to much space. */
private Dimension COMBO_SIZE = new Dimension(100, m_StartBut.getPreferredSize().height);
/** The main set of instances we're playing with. */
protected Instances m_Instances;
/** The loader used to load the user-supplied test set (if any). */
protected Loader m_TestLoader;
/** A thread that classification runs in. */
protected Thread m_RunThread;
// Register the property editors we need
static {
GenericObjectEditor.registerEditors();
}
/**
* Creates the Experiment panel.
*/
public ExperimentPanel() {
m_OutText.setEditable(false);
m_OutText.setFont(new Font("Monospaced", Font.PLAIN, 12));
m_OutText.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
m_OutText.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if ((e.getModifiers() & InputEvent.BUTTON1_MASK)
!= InputEvent.BUTTON1_MASK) {
m_OutText.selectAll();
}
}
});
m_History.setBorder(BorderFactory.createTitledBorder("Result list (right-click for options)"));
m_ClassifierEditor.setClassType(Classifier.class);
m_ClassifierEditor.setValue(ExplorerDefaults.getClassifier());
m_ClassifierEditor.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
repaint();
}
});
m_RunsSpinner.setToolTipText("The number of runs to perform");
m_RunsSpinner.setEnabled(false);
((SpinnerNumberModel) m_RunsSpinner.getModel()).setMinimum(new Integer(1));
((SpinnerNumberModel) m_RunsSpinner.getModel()).setValue(new Integer(10));
m_EvalCombo.setToolTipText("The type of evaluation to be performed");
m_EvalCombo.setEnabled(false);
m_EvalCombo.setPreferredSize(COMBO_SIZE);
m_EvalCombo.setMaximumSize(COMBO_SIZE);
m_EvalCombo.setMinimumSize(COMBO_SIZE);
m_EvalCombo.setSelectedIndex(0);
m_EvalCombo.addActionListener(n
没有合适的资源?快使用搜索试试~ 我知道了~
wekaexamples使用实例
共64个文件
java:61个
htm:2个
readme:1个
4星 · 超过85%的资源 需积分: 10 11 下载量 32 浏览量
2011-03-07
12:47:10
上传
评论
收藏 97KB RAR 举报
温馨提示
WEKA的全名是怀卡托智能分析环境(Waikato Environment for Knowledge Analysis),它的源代码就是它的安装目录下 weka-src.jar解压后得到。有一本书《数据挖掘:实用机器学习技术》第2版是和weka配套的。同时weka也是新西兰的一种鸟名,而weka的主要开发者来自新西兰。 weka作为一个公开的数据挖掘工作平台,集合了大量能承担数据挖掘任务的机器学习算法,包括对数据进行预处理,分类,回归、聚类、关联规则以及在新的交互式界面上的可视化。如果想自己实现数据挖掘算法的话,可以看一看weka的接口文档。在weka中集成自己的算法甚至借鉴它的方法自己实现可视化工具并不是件很困难的事情
资源推荐
资源详情
资源评论
收起资源包目录
wekaexamples.rar (64个子文件)
wekaexamples
filters
SingleBatch.java 2KB
RemoveMisclassifiedTest.java 2KB
FilteringOnTheFly.java 3KB
BatchFiltering.java 2KB
AddAttribute.java 4KB
RemoveTest.java 2KB
Binarize.java 4KB
DiscretizeTest.java 3KB
attributeSelection
AttributeSelectionTest.java 4KB
book
MessageClassifier.java 7KB
associations
AprioriOutput.java 2KB
clusterers
ClassesToClusters.java 2KB
ClusteringDemo.java 3KB
IncrementalClusterer.java 2KB
VisualizeClusterAssignments.java 4KB
OutputClusterDistribution.java 2KB
classifiers
CrossValidationSingleRunVariant.java 5KB
CrossValidationSingleRun.java 4KB
OutputClassDistribution.java 3KB
CostMatrixLoader.java 1KB
WekaDemo.java 7KB
CrossValidationAddPrediction.java 5KB
LoadBIF.java 2KB
IncrementalClassifier.java 2KB
M5PExample.java 5KB
CrossValidationMultipleRuns.java 4KB
core
OptionsToCode.java 3KB
neighboursearch
KDTreeWithMetaData.java 3KB
Rename.java 3KB
converters
SaveDataToAnyFile.java 2KB
SaveDataToArffFile.java 2KB
LoadDataFromDbLoaderIncremental.java 2KB
SaveDataToDbIncremental.java 3KB
LoadDataFromDbInstanceQuery.java 2KB
LoadDataFromAnyFile.java 2KB
SaveDataToDbBatch.java 2KB
SaveDataToCsvFile.java 2KB
LoadDataFromArffFile.java 2KB
LoadDataFromDbLoaderBatch.java 2KB
LoadDataFromCsvFile.java 2KB
MultiInstanceSwap.java 2KB
CreateInstances.java 4KB
DatasetAmbiguity.java 3KB
OutputGzippedArff.java 2KB
experiment
ExperimentDemo.java 9KB
gui
extensions
README 367B
SqlWorksheet.java 3KB
StartBrowser.java 2KB
treevisualizer
VisualizeJ48.java 2KB
visualize
GenerateROC.java 3KB
VisualizeROC.java 3KB
plugins
README.htm 605B
PredictionTable.java 4KB
PredictionError.java 5KB
VisualizeMultipleROC.java 3KB
VisualizeClusterAssignments.java 3KB
AttributePanelExample.java 2KB
explorer
SqlPanel.java 7KB
README.htm 1KB
GeneratorPanel.java 9KB
ExperimentPanel.java 30KB
OptionTree.java 8KB
graphvisualizer
VisualizeXMLBIF.java 2KB
VisualizeBayesNet.java 2KB
共 64 条
- 1
资源评论
- youarebaoqi2013-03-19就是weka自带的example。。。
- RonYang2013-08-22就是weka自带例子。。。weka的资料少啊!
xuwei1989404
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功