📄 decisiongentreeoperatorproperty.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.
*/
/*
* Author: achiu
* Created on 2005/1/18
* Revision: 1.0
*/
package eti.bi.alphaminer.patch.standard.operation.property;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.property.OperatorProperty;
import eti.bi.exception.SysException;
/**
* @author achiu
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DecisionGenTreeOperatorProperty extends OperatorProperty {
/**
*
*/
private static final long serialVersionUID = 1L;
private JButton m_ButtonReset = new JButton();
private JButton m_ButtonSave = new JButton();
private JButton m_ButtonCancel = new JButton();
private JTextField m_TextMinNodeSize = new JTextField();
private JTextField m_TextMaxDepth = new JTextField();
private String[] m_Options = {"Information gain", "Information gain (MC)", "Gain ratio", "Gain ratio (MC)"};
private JComboBox m_ComboImpurity = new JComboBox(m_Options);
private JTextField m_TextMinDecreaseImpurity = new JTextField();
public DecisionGenTreeOperatorProperty(String a_CaseID, String a_NodeID, INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws SysException
{
super(a_CaseID, a_NodeID, "Decision Tree properties ["+a_NodeID+"]", a_NodeInfo, a_CaseHandler);
createDecisionGenTreeOperatorProperty();
}
private void createDecisionGenTreeOperatorProperty()
{
JPanel propertyPanel = new JPanel();
JPanel buttonPanel = new JPanel();
propertyPanel.setBorder(BorderFactory.createTitledBorder("General tree algorithm"));
JLabel minNodeSize = new JLabel("Minimum node size");
JLabel maxDepth = new JLabel("Maximum tree depth");
JLabel mapValue = new JLabel("Impurity measure");
JLabel minDecreaseImpurity = new JLabel("Min. decrease in impurity");
propertyPanel.setLayout(new GridLayout(4,2));
propertyPanel.add(minNodeSize);
propertyPanel.add(m_TextMinNodeSize);
propertyPanel.add(maxDepth);
propertyPanel.add(m_TextMaxDepth);
propertyPanel.add(mapValue);
propertyPanel.add(m_ComboImpurity);
propertyPanel.add(minDecreaseImpurity);
propertyPanel.add(m_TextMinDecreaseImpurity);
m_ButtonReset.setText("Reset");
m_ButtonSave.setText("Apply");
m_ButtonCancel.setSelected(false);
m_ButtonCancel.setText("Close");
buttonPanel.add(m_ButtonSave);
buttonPanel.add(m_ButtonReset);
buttonPanel.add(m_ButtonCancel);
m_ButtonReset.addActionListener(this);
m_ButtonSave.addActionListener(this);
m_ButtonCancel.addActionListener(this);
this.getContentPane().add(propertyPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.setSize(300, 200);
getContent();
}
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == m_ButtonSave) {
if (setContent())
{
m_ParameterChanged = true;
}
} else if (e.getSource() == m_ButtonReset) {
getContent();
} else if (e.getSource() == m_ButtonCancel)
close();
}
public boolean setContent(){
/* BICase selectedCase = null;
try {
selectedCase = CaseHandler.getInstance().getCase(m_CaseID, false);
} catch (BaseException be) {
System.out.println(be.getMessage());
}
if (selectedCase == null) {
System.out.println("selected case null");
//return;
}
OperatorNode node =
(OperatorNode) selectedCase.getNode(NodeFactory.OPERATOR, m_NodeID);
if (node == null) {
System.out.println("node null " + m_NodeID);
return false;
//return;
}*/
m_Node.setParameterValue("Size", m_TextMinNodeSize.getText().trim());
m_Node.setParameterValue("Depth", m_TextMaxDepth.getText().trim());
m_Node.setParameterValue("Impurity measure", String.valueOf(m_ComboImpurity.getSelectedIndex()));
m_Node.setParameterValue("Decrease impurity", m_TextMinDecreaseImpurity.getText().trim());
//Operator op = m_ParentPanel.getOperator(m_NodeID);
//((DecisionGenTreeOperator) op).clearResult();
clearOperatorTempResult();
// m_ParentPanel.getCaseWindow().setModified(true);
setPropertiesModified();
return true;
}
public void getContent() {
/* BICase selectedCase = null;
try {
selectedCase = CaseHandler.getInstance().getCase(m_CaseID, false);
} catch (BaseException be) {
System.out.println(be.getMessage());
}
if (selectedCase == null) {
System.out.println("selected case null");
//return;
}
OperatorNode node =
(OperatorNode) selectedCase.getNode(NodeFactory.OPERATOR, m_NodeID);
if (node == null) {
System.out.println("node null " + m_NodeID);
//return;
}
*/
String size = (String) m_Node.getParameterValue("Size");
if (size!=null)
m_TextMinNodeSize.setText(size);
else
m_TextMinNodeSize.setText("0");
String depth = (String) m_Node.getParameterValue("Depth");
if (depth!=null)
m_TextMaxDepth.setText(depth);
else
m_TextMaxDepth.setText("100");
String impurity = (String) m_Node.getParameterValue("Impurity measure");
if (impurity==null)
impurity = "0";
m_ComboImpurity.setSelectedIndex(Integer.parseInt(impurity));
String decrease = (String) m_Node.getParameterValue("Decrease impurity");
if (decrease!=null)
m_TextMinDecreaseImpurity.setText(decrease);
else
m_TextMinDecreaseImpurity.setText("0.1");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -