📄 multilayerperceptronoperatorproperty.java
字号:
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.alphaminer.patch.standard.operation.operator.MultilayerPerceptronOperator;
import eti.bi.common.Locale.Resource;
import eti.bi.exception.SysException;
public class MultilayerPerceptronOperatorProperty extends OperatorProperty{
/* UI controls */
private static final long serialVersionUID = -2104856718942630953L;
private JButton m_ButtonReset = new JButton();
private JButton m_ButtonSave = new JButton();
private JButton m_ButtonCancel = new JButton();
private JComboBox m_ListGui;
private JLabel m_LabelAutobuild = new JLabel(Resource.srcStr("m_autobuild"));
private JComboBox m_ListAutobuild;
private JLabel m_LabelDecay = new JLabel(Resource.srcStr("m_decay"));
private JComboBox m_ListDecay;
private JLabel m_LabelHiddenLayers = new JLabel(Resource.srcStr("m_hiddenlayers"));
private JComboBox m_ListHiddenLayers;
private JLabel m_LableLearningRates = new JLabel(Resource.srcStr("m_learningRates"));
private JTextField m_TextLearningRates = new JTextField(10);
private JLabel m_Momentum = new JLabel(Resource.srcStr("m_momentum"));
private JTextField m_TextMomentum = new JTextField(10);
private JLabel m_LabelNominalToBinaryFilter = new JLabel(Resource.srcStr("m_nominalToBinaryFilter"));
private JComboBox m_ListNominalToBinaryFilter;
private JLabel m_LabelNormalizeAttributes = new JLabel(Resource.srcStr("m_normalizeAttributes"));
private JComboBox m_ListNormalizeAttributes;
private JLabel NormalizeNumericClass = new JLabel(Resource.srcStr("m_normalizeNumericClass"));
private JComboBox m_ListNormalizeNumericClass;
private JLabel m_RandomSeed = new JLabel(Resource.srcStr("m_randomSeed"));
private JTextField m_TextRandomSeed = new JTextField(10);
private JLabel m_LabelReset = new JLabel(Resource.srcStr("m_Reset"));
private JComboBox m_ListReset;
private JLabel m_TrainingTime = new JLabel(Resource.srcStr("m_trainingTime"));
private JTextField m_TextTrainingTime = new JTextField(10);
private JLabel m_ValidationSetSize = new JLabel(Resource.srcStr("m_validationSetSize"));
private JTextField m_TextValidationSetSize = new JTextField(10);
private JLabel m_ValidationThreshold = new JLabel(Resource.srcStr("m_validationThreshold"));
private JTextField m_TextValidationThreshold = new JTextField(10);
/**
* Constructs an NavieBayesOperatorProject object.
* @param a_CaseID
* ID of the Case containing the Operator Node to be set by this
* DecisionTreeOperatorProperty.
* @param a_NodeID
* ID of the Operator node to be set by this
* DecisionTreeOperatorProperty.
* @throws SysException
*/
public MultilayerPerceptronOperatorProperty(String a_CaseID, String a_NodeID, String a_Name, INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws SysException {
super(a_CaseID, a_NodeID, "MultilayerPerceptron [" + a_NodeID + "]", a_NodeInfo, a_CaseHandler);
createNavieBayesOperatorProperty();
this.setTitle(Resource.srcStr("MultilayerPerceptron")+" ["+a_NodeID+"]");
}
/**
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == m_ButtonSave) {
if (applyContent()) {
m_ParameterChanged = true;
}
} else if (e.getSource() == m_ButtonReset) {
getContent();
} else if (e.getSource() == m_ButtonCancel)
close();
}
private boolean applyContent() {
if (validateProperty()) {
return setContent();
} else {
return false;
}
}
private void createNavieBayesOperatorProperty() {
JPanel propertyPanel = new JPanel();
JPanel buttonPanel = new JPanel();
/*propertyPanel*/
propertyPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(Resource.srcStr("MultilayerPerceptron")),
BorderFactory.createEmptyBorder(2,4,0,6)));
// set list data
m_ListGui= new JComboBox(new String[]{"true","false"});
m_ListAutobuild = new JComboBox(new String[]{"true","false"});
m_ListDecay = new JComboBox(new String[]{"true","false"});
m_ListHiddenLayers = new JComboBox(new String[]{"a","i","o","t"});
m_ListNominalToBinaryFilter = new JComboBox(new String[]{"true","false"});
m_ListNormalizeAttributes = new JComboBox(new String[]{"true","false"});
m_ListNormalizeNumericClass = new JComboBox(new String[]{"true","false"});
m_ListReset = new JComboBox(new String[]{"true","false"});
//create panel
GridLayout gl = new GridLayout(1,2,0,5);
JPanel AutobuildPanel = new JPanel(gl);
AutobuildPanel.add(m_LabelAutobuild, BorderLayout.WEST);
AutobuildPanel.add(m_ListAutobuild, BorderLayout.EAST);
JPanel DecayPanel = new JPanel(gl);
DecayPanel.add(m_LabelDecay, BorderLayout.WEST);
DecayPanel.add(m_ListDecay, BorderLayout.EAST);
JPanel HiddenLayersPanel = new JPanel(gl);
HiddenLayersPanel.add(m_LabelHiddenLayers, BorderLayout.WEST);
HiddenLayersPanel.add(m_ListHiddenLayers, BorderLayout.EAST);
JPanel LearningRatesPanel = new JPanel(gl);
LearningRatesPanel.add(m_LableLearningRates, BorderLayout.WEST);
LearningRatesPanel.add(m_TextLearningRates, BorderLayout.EAST);
JPanel MomentumPanel = new JPanel(gl);
MomentumPanel.add(m_Momentum, BorderLayout.WEST);
MomentumPanel.add(m_TextMomentum, BorderLayout.EAST);
JPanel NominalToBinaryFilterPanel = new JPanel(gl);
NominalToBinaryFilterPanel.add(m_LabelNominalToBinaryFilter, BorderLayout.WEST);
NominalToBinaryFilterPanel.add(m_ListNominalToBinaryFilter, BorderLayout.EAST);
JPanel NormalizeAttributesPanel = new JPanel(gl);
NormalizeAttributesPanel.add(m_LabelNormalizeAttributes, BorderLayout.WEST);
NormalizeAttributesPanel.add(m_ListNormalizeAttributes, BorderLayout.EAST);
JPanel NormalizeNumericClassPanel = new JPanel(gl);
NormalizeNumericClassPanel.add(NormalizeNumericClass, BorderLayout.WEST);
NormalizeNumericClassPanel.add(m_ListNormalizeNumericClass, BorderLayout.EAST);
JPanel RandomSeedPanel = new JPanel(gl);
RandomSeedPanel.add(m_RandomSeed, BorderLayout.WEST);
RandomSeedPanel.add(m_TextRandomSeed, BorderLayout.EAST);
JPanel ResetPanel = new JPanel(gl);
ResetPanel.add(m_LabelReset, BorderLayout.WEST);
ResetPanel.add(m_ListReset, BorderLayout.EAST);
JPanel TrainingTimePanel = new JPanel(gl);
TrainingTimePanel.add(m_TrainingTime, BorderLayout.WEST);
TrainingTimePanel.add(m_TextTrainingTime, BorderLayout.EAST);
JPanel ValidationSetSizePanel = new JPanel(gl);
ValidationSetSizePanel.add(m_ValidationSetSize, BorderLayout.WEST);
ValidationSetSizePanel.add(m_TextValidationSetSize, BorderLayout.EAST);
JPanel ValidationThresholdPanel = new JPanel(gl);
ValidationThresholdPanel.add(m_ValidationThreshold, BorderLayout.WEST);
ValidationThresholdPanel.add(m_TextValidationThreshold, BorderLayout.EAST);
//add
propertyPanel.setLayout(new GridLayout(13, 2, 0, 5));
//propertyPanel.add(GuiPanel);
propertyPanel.add(AutobuildPanel);
propertyPanel.add(DecayPanel);
propertyPanel.add(HiddenLayersPanel);
propertyPanel.add(LearningRatesPanel);
propertyPanel.add(MomentumPanel);
propertyPanel.add(NominalToBinaryFilterPanel);
propertyPanel.add(NormalizeAttributesPanel);
propertyPanel.add(NormalizeNumericClassPanel);
propertyPanel.add(RandomSeedPanel);
propertyPanel.add(ResetPanel);
propertyPanel.add(TrainingTimePanel);
propertyPanel.add(ValidationSetSizePanel);
propertyPanel.add(ValidationThresholdPanel);
/*button panel*/
m_ButtonReset.setText(Resource.srcStr("m_ButtonReset"));
m_ButtonSave.setText(Resource.srcStr("m_ButtonApply"));
m_ButtonCancel.setSelected(false);
m_ButtonCancel.setText(Resource.srcStr("m_ButtonClose"));
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(350, 540);
initContent();
getContent();
}
/**
* Set values input in this NavieBayesOperatorProperty to the Operator Node.
*/
public boolean setContent(){
if(m_Node==null){
return false;
}
if(m_ListGui.getSelectedIndex()==1)
{
}
else if(m_ListGui.getSelectedIndex()==0)
{
}
//m_Node.setParameterValue(MultilayerPerceptronOperator.GUI, mm_gui);
//m_Node.removeParameterValue(MultilayerPerceptronOperator.AUTOBUILD);
String mm_autobuild=null;
if(m_ListAutobuild.getSelectedIndex()==1)
{
mm_autobuild= " -A ";
}
else if(m_ListAutobuild.getSelectedIndex()==0)
{
mm_autobuild=" ";
}
m_Node.setParameterValue(MultilayerPerceptronOperator.AUTOBUILD, mm_autobuild);
//m_Node.removeParameterValue(MultilayerPerceptronOperator.DECAY);
String mm_decay=null;
if(m_ListDecay.getSelectedIndex()==1)
{
mm_decay=" -D ";
}
else if(m_ListDecay.getSelectedIndex()==0)
{
mm_decay=" ";
}
m_Node.setParameterValue(MultilayerPerceptronOperator.DECAY, mm_decay);
//m_Node.removeParameterValue(MultilayerPerceptronOperator.HIDDENLAYERS);
m_Node.setParameterValue(MultilayerPerceptronOperator.HIDDENLAYERS,(String) m_ListHiddenLayers.getSelectedItem());
//m_Node.removeParameterValue(MultilayerPerceptronOperator.LEARNINGRATE);
m_Node.setParameterValue(MultilayerPerceptronOperator.LEARNINGRATE, m_TextLearningRates.getText());
//m_Node.removeParameterValue(MultilayerPerceptronOperator.MOMENTUM);
m_Node.setParameterValue(MultilayerPerceptronOperator.MOMENTUM, m_TextMomentum.getText());
//m_Node.removeParameterValue(MultilayerPerceptronOperator.NOMINALTOBINARYFILTER);
String mm_nominaltobinaryfilter=null;
if(m_ListNominalToBinaryFilter.getSelectedIndex()==1)
{
mm_nominaltobinaryfilter=" -B ";
}
else if(m_ListNominalToBinaryFilter.getSelectedIndex()==0)
{
mm_nominaltobinaryfilter=" ";
}
m_Node.setParameterValue(MultilayerPerceptronOperator.NOMINALTOBINARYFILTER, mm_nominaltobinaryfilter);
//m_Node.removeParameterValue(MultilayerPerceptronOperator.NORMALIZEATTRIBUTES);
String mm_normalizeattributes=null;
if(m_ListNormalizeAttributes.getSelectedIndex()==1)
{
mm_normalizeattributes=" -I ";
}
else if(m_ListNormalizeAttributes.getSelectedIndex()==0)
{
mm_normalizeattributes=" ";
}
m_Node.setParameterValue(MultilayerPerceptronOperator.NORMALIZEATTRIBUTES, mm_normalizeattributes);
//m_Node.removeParameterValue(MultilayerPerceptronOperator.NORMALIZENUMERICCLASS);
String mm_normalizenumericclass=null;
if(m_ListNormalizeNumericClass.getSelectedIndex()==1)
{
mm_normalizenumericclass=" -C ";
}
else if(m_ListNormalizeNumericClass.getSelectedIndex()==0)
{
mm_normalizenumericclass=" ";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -