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

📄 tutorial.java

📁 一个很好的LIBSVM的JAVA源码。对于要研究和改进SVM算法的学者。可以参考。来自数据挖掘工具YALE工具包。
💻 JAVA
字号:
/*
 *  YALE - Yet Another Learning Environment
 *  Copyright (C) 2001-2004
 *      Simon Fischer, Ralf Klinkenberg, Ingo Mierswa, 
 *          Katharina Morik, Oliver Ritthoff
 *      Artificial Intelligence Unit
 *      Computer Science Department
 *      University of Dortmund
 *      44221 Dortmund,  Germany
 *  email: yale-team@lists.sourceforge.net
 *  web:   http://yale.cs.uni-dortmund.de/
 *
 *  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 *  USA.
 */
package edu.udo.cs.yale.gui;

import edu.udo.cs.yale.Yale;
import edu.udo.cs.yale.Experiment;
import edu.udo.cs.yale.tools.ParameterService;

import javax.swing.*;
import java.awt.event.*;
import java.awt.Font;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.plaf.FontUIResource;

import java.io.File;

public class Tutorial extends JDialog {

    static {
	UIDefaults uiDefaults = UIManager.getDefaults();
	Font f = new Font("SansSerif", Font.PLAIN, 12);
	Font font = new FontUIResource(f);
	
	uiDefaults.put("EditorPane.font", font);
    }

    private static final String START_TEXT = "<h2>Welcome to the Yale online tutorial!</h2><p>This tutorial demonstrates basic concepts of Yale and simple experiments which can be performed. The user should have some knowledge in the domain of machine learning and data mining.</p><p>Whenever this tutorial refers to the &quot;Yale Tutorial&quot;, it means the printed version available at<br><center><code>http://yale.cs.uni-dortmund.de</code></center></p><p>You should read the first chapter of the Yale Tutorial for better motivation, but you can also try to start with the online tutorial without reading the printed version. Please read the texts carefully and try at least the suggested steps. The online tutorial will take about one hour.</p>";

    private static final String END_TEXT = "<h2>Congratulations!</h2><p>You have finished the Yale online tutorial. You should be able to perform many of the possible experiments. Now you know the most important building blocks of data mining experiments. Of course these building blocks can be arbitrarily nested in Yale as long as their input and output types fits. For a reference of all operators please refer to the Yale Tutorial. Check also the other sample experiments which can be found in the sample directory of Yale.</p><p>We have added many known preprocessing steps and learning operators to Yale. Most data formats can also be handled. If you need to adapt Yale you should read the chapter of the Yale Tutorial which describes the creation of operators and the extension mechanism. Yale can easily be extended. Have fun!</p>";

    private static final String[] EXPERIMENTS = new String[] {
	"Empty.xml",
	"Input.xml",
	"DecisionTree.xml",
	"ModelWriter.xml", 
	"ModelLoader.xml",
	"Sparse.xml", 
	"ArffTest.xml",
	"MissingValueReplenishment.xml",
	"Noise.xml",
	"XValidation.xml",
	"WekaMetaLearning.xml",
	"ForwardSelection.xml",
	"YAGGA.xml", 
	"YAGGAResultAttributeSetting.xml",
	"FeatureGeneration.xml",
	"FeatureWeighting.xml", 
	"EnsembleLearning.xml",
	"ParameterOptimization.xml"
    };


    private int state = 0;
    private MainFrame mainFrame;
    private JEditorPane description;
    private JScrollPane descriptionScrollPane;
    private JButton prevButton, nextButton;

    public Tutorial(MainFrame mainFrame) {
	super(mainFrame, "Yale Tutorial", false);
	this.mainFrame = mainFrame;

	JPanel rootPanel = new JPanel(new BorderLayout());
	rootPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
	GridBagLayout layout = new GridBagLayout();
	JPanel mainPanel = new JPanel(layout);
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.ipadx = 10;
	c.ipady = 10;
	c.weightx = 1.0d;
	c.weighty = 1.0d;

	description = new JEditorPane("text/html", SwingTools.text2DisplayHtml(START_TEXT));
	description.setEditable(false);
	description.setBackground(this.getBackground());
	descriptionScrollPane = new JScrollPane(description);
	c.gridwidth = GridBagConstraints.REMAINDER;
	layout.setConstraints(descriptionScrollPane, c);
	mainPanel.add(descriptionScrollPane);
	c.weighty = 0.0d;

	rootPanel.add(mainPanel, BorderLayout.CENTER);

	JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	prevButton = new JButton("Previous");
	prevButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) { 
		    previous(); 
		}
	    });
	prevButton.setEnabled(false);
	buttonPanel.add(prevButton);
	nextButton = new JButton("Next");
	nextButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) { 
		    next(); 
		}
	    });
	buttonPanel.add(nextButton);
	JButton closeButton = new JButton("Close");
	closeButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) { 
		    close(); 
		}
	    });
	buttonPanel.add(closeButton);
	rootPanel.add(buttonPanel, BorderLayout.SOUTH);

	getContentPane().add(rootPanel);

	pack();
	setSize(400, 600);
	setLocationRelativeTo(mainFrame);
	mainFrame.setTutorialMode(true);
    }

    private void setExperiment(String experiment) {
	File expFile = new File(ParameterService.getYaleHome(), "sample" + File.separator + experiment);
	mainFrame.open(expFile, false);
	description.setText(SwingTools.text2DisplayHtml(Yale.getExperiment().getRootOperator().getUserDescription()));
	description.getCaret().setDot(0);
	descriptionScrollPane.getVerticalScrollBar().setValue(0);
    }

    private void previous() {
	nextButton.setEnabled(true);
	if (state > 0) state--;
	if (state == 0) {
	    prevButton.setEnabled(false);
	    description.setText(SwingTools.text2DisplayHtml(START_TEXT));
	} else {
	    setExperiment(EXPERIMENTS[state - 1]);
	}
    }

    private void next() {
	prevButton.setEnabled(true);
	if (state < EXPERIMENTS.length + 1) state++;
	if (state == EXPERIMENTS.length + 1) {
	    nextButton.setEnabled(false);
	    description.setText(SwingTools.text2DisplayHtml(END_TEXT));
	} else {
	    setExperiment(EXPERIMENTS[state - 1]);
	}
    }

    private void close() {
	mainFrame.setExperiment(new Experiment());
	mainFrame.setTutorialMode(false);
	dispose();
    }
}

⌨️ 快捷键说明

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