Skip to content

Commit 8036c23

Browse files
committed
now displays a helpful error message rather than producing a NPE when there is no performance data available
1 parent 42e71ab commit 8036c23

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/java/meka/gui/explorer/classify/IncrementalPerformance.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1414
*/
1515

16-
/**
16+
/*
1717
* IncrementalPerformance.java
18-
* Copyright (C) 2015 University of Waikato, Hamilton, NZ
18+
* Copyright (C) 2015-2024 University of Waikato, Hamilton, NZ
1919
*/
2020

2121
package meka.gui.explorer.classify;
2222

2323
import meka.classifiers.multilabel.IncrementalMultiLabelClassifier;
2424
import meka.core.Result;
2525
import meka.gui.core.ResultHistoryList;
26+
import nz.ac.waikato.cms.gui.core.GUIHelper;
2627
import weka.core.Instances;
2728
import weka.gui.visualize.PlotData2D;
2829
import weka.gui.visualize.ThresholdVisualizePanel;
@@ -34,10 +35,9 @@
3435
import java.awt.event.ActionListener;
3536

3637
/**
37-
* Allows the user to displays graphs of the performance of an incremental classifier if available.
38+
* Allows the user to display graphs of the performance of an incremental classifier if available.
3839
*
3940
* @author FracPete (fracpete at waikato dot ac dot nz)
40-
* @version $Revision$
4141
*/
4242
public class IncrementalPerformance
4343
extends AbstractClassifyResultHistoryPlugin {
@@ -119,6 +119,10 @@ public void actionPerformed(ActionEvent e) {
119119
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
120120
dialog.getContentPane().setLayout(new BorderLayout());
121121
Instances performance = (Instances) result.getMeasurement(RESULTS_SAMPLED_OVER_TIME);
122+
if (performance == null) {
123+
GUIHelper.showErrorMessage(getOwner().getParent(), "No performance data available for plotting! The classifier needs to be evaluated in prequential or batch-incremental mode.");
124+
return;
125+
}
122126
try {
123127
VisualizePanel panel = createPanel(performance);
124128
dialog.getContentPane().add(panel, BorderLayout.CENTER);

0 commit comments

Comments
 (0)