📄 predictionassessmentoperatorproperty.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.
*/
/*
* Created on 2005-1-15
*
* $Author$
* $Date$
* $Revision$
* $Refactored by Frank J. Xu, 25/01/2005
*/
package eti.bi.alphaminer.patch.standard.operation.property;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Hashtable;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import com.prudsys.pdm.Core.MiningAttribute;
import eti.bi.alphaminer.core.handler.ICaseHandler;
import eti.bi.alphaminer.operation.operator.INodeInfo;
import eti.bi.alphaminer.operation.operator.ModelOperator;
import eti.bi.alphaminer.operation.operator.Operator;
import eti.bi.alphaminer.operation.property.OperatorProperty;
import eti.bi.alphaminer.patch.standard.operation.operator.PredictionAssessmentOperator;
import eti.bi.alphaminer.patch.standard.operation.operator.PredictionAssessmentOperatorUtil;
import eti.bi.exception.SysException;
import eti.bi.common.Locale.Resource;
/**
* @author twang
*/
public class PredictionAssessmentOperatorProperty extends OperatorProperty implements ChangeListener {
/**
*
*/
private static final long serialVersionUID = -1164102220567449508L;
public static final Border PANEL_INNER_SPACING_THIN = new EmptyBorder(8, 8, 4, 8);
public static final Border ETCHED_BORDER_INNER_SPACING_THIN = new CompoundBorder(new EtchedBorder(
EtchedBorder.LOWERED), new EmptyBorder(12, 12, 12, 12));
private PredictionAssessmentOperator m_Operator;
private ArrayList<String> modelNamesList;
private ArrayList datasetsList;
private ArrayList datasetsIDList;
// <<30/06/2005 Mark Li: Modify for Evauation target value
private ArrayList m_TargetValueSet;
// 30/06/2005 Mark Li: Modify for Evauation target value>>
private JPanel assessmentPanel;
private JScrollPane modelsPane;
private JScrollPane datasetsPane;
private JPanel thresholdPanel;
private JPanel buttonsPanel;
private GridLayout gridLayout;
private JPanel tablePanel;
// Variables to record the assessment node parameter settings.
private double thresholdValue;
private JLabel thresholdLabel;
private JSlider thresholdSlider;
// <<30/06/2005 Mark Li: Modify for Evauation target value
// private JRadioButton zeroRadioButton;
// private JRadioButton oneRadioButton;
private JComboBox targetEventLevelComboBox;
// 30/06/2005 Mark Li: Modify for Evauation target value>>
private JRadioButton selectMatrixRadioButton;
private JRadioButton selectEvaRadioButton;
private AccessmentOperatorTableModel modelsTableModel;
private AccessmentOperatorTableModel dataSetsTableModel;
private PredictionAssessmentOperatorUtil m_AssessmentOperatorUtil;
private static ButtonGroup buttonGroup = new ButtonGroup();
private JComboBox chartTypeComboBox;
private JComboBox drawStyleComboBox;
private JTable modelsTable;
private JTable datasetsTable;
private JButton buttonApply;
private JButton buttonReset;
private JButton buttonClose;
private Object[][] dataSetsArray;
private Object[][] modelsArray;
private final static int tableColumnNum = 2;
// <<01/02/2005 Mark Li: Add two column name and modify the column size of
// table
public final static int checkColumnSize = 50;
// 01/02/2005 Mark Li>>
// These parameters are needed by the visualization part
public static String DRAW_STYLE_LINE = Resource.srcStr("ASSESSMENT_LINE");
public static String DRAW_STYLE_POINT = Resource.srcStr("ASSESSMENT_POINT");
public static String CHART_TYPE_CUMULATIVE_GAIN = Resource.srcStr("ASSESSMENT_GAIN_CHART");
public static String CHART_TYPE_LIFT = Resource.srcStr("ASSESSMENT_LIFT_CHART");
/**
* @param a_CaseID
* @param a_NodeID
* @param a_Name
* @throws HeadlessException
* @throws SysException
*/
public PredictionAssessmentOperatorProperty(String a_CaseID, String a_NodeID, String a_Name,
INodeInfo a_NodeInfo, ICaseHandler a_CaseHandler) throws HeadlessException, SysException {
super(a_CaseID, a_NodeID, Resource.srcStr("Assessment") + " [" + a_NodeID + "]", a_NodeInfo, a_CaseHandler);
m_Operator = (PredictionAssessmentOperator) m_CaseHandler.getOperator(m_CaseID, m_NodeID);
m_AssessmentOperatorUtil = new PredictionAssessmentOperatorUtil(m_CaseID, m_NodeID, m_CaseHandler);
createAssessmentOperatorProperty();
this.resizable = false;
}
/**
* @throws SysException
*
*/
private void createAssessmentOperatorProperty() throws SysException {
assessmentPanel = new JPanel(new GridBagLayout());
gridLayout = new GridLayout(2, 1, 0, 8);
tablePanel = new JPanel(gridLayout);
assessmentPanel.setBorder(PANEL_INNER_SPACING_THIN);
// Create Pane.
try {
createModelsPane();
} catch (Exception e) {
throw new SysException(e);
}
createDatasetsPane();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.95;
c.weighty = 1.0;
c.gridheight = 2;
c.anchor = GridBagConstraints.EAST;
// c.insets = new Insets(10, 25, 20, 20);
c.insets = new Insets(0, 0, 2, 12);
assessmentPanel.add(tablePanel, c);
// create the common radio button group
buttonGroup = new ButtonGroup();
createConfusionMatricesPanel();
createEvaluationPanel();
createButtonsPanel();
restorePreviousContent();
getContentPane().setLayout(new BorderLayout(0, 0));
this.getContentPane().add(assessmentPanel, BorderLayout.CENTER);
this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
((JPanel) getContentPane()).setBorder(new EmptyBorder(0, 0, 4, 0));
setSize(630, 305);
// setResizable(false);
}
private void createModelsPane() throws Exception{
createModelTable();
JPanel createModelTablePanel = new JPanel(new BorderLayout(0, 2));
modelsPane = new JScrollPane(modelsTable);
modelsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
modelsPane.getViewport().setBackground(Color.WHITE);
createModelTablePanel.add(new JLabel(Resource.srcStr("ModelLabel")), BorderLayout.NORTH);
createModelTablePanel.add(modelsPane, BorderLayout.CENTER);
tablePanel.add(createModelTablePanel);
}
public void setModelArray(ArrayList<String> accessModel) {
if (accessModel != null && accessModel.size() > 0) {
modelsArray = new Object[accessModel.size()][2];
for (int i = 0; i < accessModel.size(); i++) {
modelsArray[i][0] = accessModel.get(i);
modelsArray[i][1] = new Boolean(false);
}
}
}
public Object[][] getModelArray() {
// if (modelsArray == null)
// System.err.println("*********Warning: modelsArray is null");
return modelsArray;
}
/**
* Create the Model list according to the input model Should input a list of
* Models.
*
* @return
*/
private void createModelTable() throws Exception{
modelNamesList = new ArrayList<String>();
// Only decision tree and logistic rergerssion models can be
// evaluated.
if(m_ParentOperators != null){
for (int i=0; i<m_ParentOperators.size(); i++){
Operator parentOp = (Operator)(m_ParentOperators.elementAt(i));
// TODO Get DefaultModelName from the modeloperator instead of output
// BIModel
if (parentOp instanceof ModelOperator)
{
MiningAttribute targetAttribute = parentOp.getOutputBIObject().getBIModel().getTargetAttribute();
m_AssessmentOperatorUtil.setTargetAttributeValue(targetAttribute);
modelNamesList.add(((ModelOperator)parentOp).getDefaultModelName());
}
}
}
setModelArray(modelNamesList);
modelsTableModel = new AccessmentOperatorTableModel(getModelArray());
modelsTable = new JTable(modelsTableModel);
modelsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
modelsTable.getTableHeader().setReorderingAllowed(false);
TableColumn column = modelsTable.getColumnModel().getColumn(1);
column.setMinWidth(checkColumnSize);
column.setMaxWidth(checkColumnSize);
column.setPreferredWidth(checkColumnSize);
// modelsTable.setPreferredSize(new Dimension(199, 100));
modelsTable.setLayout(new BoxLayout(modelsTable, BoxLayout.Y_AXIS));
}
public void setDataSetsArray(ArrayList datasets) {
if (datasets != null && datasets.size() > 0) {
dataSetsArray = new Object[datasets.size()][2];
for (int i = 0; i < datasets.size(); i++) {
dataSetsArray[i][0] = datasets.get(i);
dataSetsArray[i][1] = new Boolean(false);
}
}
}
public Object[][] getDataSetsArray() {
// if (dataSetsArray == null)
// System.err.println("*********Warning: dataSetsArray is null");
return dataSetsArray;
}
private void createDatasetsPane() throws SysException {
createDatasetTable();
JPanel DatasetsTablePanel = new JPanel(new BorderLayout(0, 2));
DatasetsTablePanel.add(new JLabel(Resource.srcStr("DataSetLabel")), BorderLayout.NORTH);
datasetsPane = new JScrollPane(datasetsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
datasetsPane.getViewport().add(datasetsTable);
datasetsPane.setPreferredSize(new Dimension(1, 1));
datasetsTable.setPreferredScrollableViewportSize(new Dimension(1, 1));
datasetsPane.getViewport().setBackground(Color.WHITE);
DatasetsTablePanel.add(datasetsPane, BorderLayout.CENTER);
tablePanel.add(DatasetsTablePanel);
}
private void createDatasetTable() throws SysException {
datasetsList = new ArrayList();
datasetsIDList = new ArrayList();
// PredictionAssessmentOperatorUtil assessmentOperatorUtil = new
// PredictionAssessmentOperatorUtil(m_CaseID, m_NodeID, m_CaseHandler);
m_AssessmentOperatorUtil.addDataSet(m_Operator, datasetsList, datasetsIDList);
setDataSetsArray(datasetsList);
dataSetsTableModel = new AccessmentOperatorTableModel(getDataSetsArray());
datasetsTable = new JTable(dataSetsTableModel);
// <<30/06/2005 Mark Li: Modify for Evauation target value
m_TargetValueSet = m_AssessmentOperatorUtil.getTargetAttributeValue();
// 30/06/2005 Mark Li: Modify for Evauation target value>>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -