Java Reference
In-Depth Information
4.
mConfusionMatrix = iTestMetrics.getConfusionMatrix();
5.
setLayout(new BorderLayout());
6.
JPanel lMetricsGeneralInfos new JPanel(new GridLayout());
7.
lMetricsGeneralInfos.add(new JLabel("Accuracy:", JLabel.RIGHT));
8.
lMetricsGeneralInfos.add(
9.
new JLabel(iTestMetrics.getAccuracy().toString()));
10.
add(lMetricsGeneralInfos, BorderLayout.NORTH);
11.
JTabbedPane lTabbedPane new JTabbedPane();
12.
lTabbedPane.add("Lift", createLiftDisplayer());
13.
lTabbedPane.add("ROC", createROCDisplayer());
14.
lTabbedPane.add("Confusion Matrix",
15.
createConfusionMatrixDisplayer());
16.
add(lTabbedPane, BorderLayout.CENTER);
17. }
We will not fully describe here the panes concerning the ROC or
the confusion matrix since the reader has seen already how to fill
graphical tables with information from JDM objects. However, we
select the lift object, focusing on the createLiftDisplayer, to illustrate
user interaction since that requires more explanation. We divide this
code into several sections to explain this user interaction.
1. private JPanel createLiftDisplayer() {
2.
JPanel lLiftDisplayer new JPanel(new BorderLayout());
3.
JPanel lSliderPanel new JPanel(new FlowLayout());
4.
final JSlider lLowerIndexSlider
5.
new JSlider(0, mLift.getNumberOfQuantiles() 1, 0);
6.
final JLabel lLowerLabel new JLabel("000");
7.
lSliderPanel.add(new JLabel("Lower Quantile:", JLabel.RIGHT));
8.
lSliderPanel.add(lLowerIndexSlider);
9.
lSliderPanel.add(lLowerLabel);
10.
final JLabel lUpperLabel new JLabel("000");
11.
final JSlider lUpperIndexSlider
12.
new JSlider(0, mLift.getNumberOfQuantiles() 1, 0);
13.
lSliderPanel.add(new JLabel("Upper Quantile:", JLabel.RIGHT));
14.
lSliderPanel.add(lUpperIndexSlider);
15.
lSliderPanel.add(lUpperLabel);
The overall graphical component is the lLiftDisplayer, which is
itself decomposed into two parts. The upper part displays two
sliders to tune the lower and upper quantiles, defining a segment of
the population managed by the lSliderPanel. The lower part displays
the statistics about the selected segment, as shown here:
JPanel lIndicatorsPanel new JPanel(new GridLayout(5, 4, 5, 5));
16.
final JLabel lLiftLabel new JLabel();
17.
 
Search WWH ::




Custom Search