@@ -298,6 +298,10 @@ class OWROCAnalysis(widget.OWWidget):
298298 priority = 1010
299299 inputs = [("Evaluation Results" , Orange .evaluation .Results , "set_results" )]
300300
301+ class Warning (widget .OWWidget .Warning ):
302+ empty_results = widget .Msg (
303+ "Empty results on input. There is nothing to display." )
304+
301305 target_index = settings .Setting (0 )
302306 selected_classifiers = []
303307
@@ -418,8 +422,10 @@ def set_results(self, results):
418422 self .clear ()
419423 self .results = check_results_adequacy (results , self .Error )
420424 if self .results is not None :
421- self ._initialize (results )
425+ self ._initialize (self . results )
422426 self ._setup_plot ()
427+ else :
428+ self .warning ()
423429
424430 def clear (self ):
425431 """Clear the widget state."""
@@ -517,7 +523,7 @@ def _setup_plot(self):
517523 if self .display_convex_curve :
518524 self .plot .addItem (graphics .hull_item )
519525
520- if self .display_def_threshold :
526+ if self .display_def_threshold and curve . is_valid :
521527 points = curve .points
522528 ind = numpy .argmin (numpy .abs (points .thresholds - 0.5 ))
523529 item = pg .TextItem (
@@ -559,6 +565,8 @@ def _setup_plot(self):
559565 if self .display_convex_curve :
560566 self .plot .addItem (fold .hull_item )
561567 hull_curves = [fold .hull for curve in selected for fold in curve .folds ]
568+ else :
569+ assert False
562570
563571 if self .display_convex_hull and hull_curves :
564572 hull = convex_hull (hull_curves )
@@ -578,6 +586,14 @@ def _setup_plot(self):
578586 if self .roc_averaging == OWROCAnalysis .Merge :
579587 self ._update_perf_line ()
580588
589+ warning = ""
590+ if not all (c .is_valid for c in hull_curves ):
591+ if any (c .is_valid for c in hull_curves ):
592+ warning = "Some ROC curves are undefined"
593+ else :
594+ warning = "All ROC curves are undefined"
595+ self .warning (warning )
596+
581597 def _on_target_changed (self ):
582598 self .plot .clear ()
583599 self ._setup_plot ()
@@ -612,10 +628,13 @@ def _update_perf_line(self):
612628 self .fp_cost , self .fn_cost , self .target_prior / 100.0 )
613629
614630 hull = self ._rocch
615- ind = roc_iso_performance_line (m , hull )
616- angle = numpy .arctan2 (m , 1 ) # in radians
617- self ._perf_line .setAngle (angle * 180 / numpy .pi )
618- self ._perf_line .setPos ((hull .fpr [ind [0 ]], hull .tpr [ind [0 ]]))
631+ if hull .is_valid :
632+ ind = roc_iso_performance_line (m , hull )
633+ angle = numpy .arctan2 (m , 1 ) # in radians
634+ self ._perf_line .setAngle (angle * 180 / numpy .pi )
635+ self ._perf_line .setPos ((hull .fpr [ind [0 ]], hull .tpr [ind [0 ]]))
636+ else :
637+ self ._perf_line .setVisible (False )
619638
620639 def onDeleteWidget (self ):
621640 self .clear ()
0 commit comments