1111 Qt , QSize , QRect , QRectF , QPoint , QLocale ,
1212 QModelIndex , QAbstractTableModel , QSortFilterProxyModel , pyqtSignal , QTimer )
1313
14+ from orangewidget .report import plural
15+
1416import Orange
1517from Orange .evaluation import Results
1618from Orange .base import Model
@@ -293,19 +295,29 @@ def _set_errors(self):
293295 self .Warning .wrong_targets .clear ()
294296
295297 def _update_info (self ):
296- n_predictors = len (self .predictors )
297- if not self .data and not n_predictors :
298+ if not self .data and not self .predictors :
298299 self .info .set_input_summary (self .info .NoInput )
299300 return
300301
301- n_valid = len (self ._non_errored_predictors ())
302302 summary = str (len (self .data )) if self .data else "0"
303- details = f"{ len (self .data )} instances" if self .data else "No data"
304- details += f"\n { n_predictors } models" if n_predictors else "No models"
305- if n_valid != n_predictors :
306- details += f" ({ n_predictors - n_valid } failed)"
303+ details = self ._get_details ()
307304 self .info .set_input_summary (summary , details )
308305
306+ def _get_details (self ):
307+ n_predictors = len (self .predictors )
308+ if self .data :
309+ details = plural ("{number} instance{s}" , len (self .data ))
310+ else :
311+ details = "No data"
312+ if n_predictors :
313+ n_valid = len (self ._non_errored_predictors ())
314+ details += plural ("\n {number} model{s}" , n_predictors )
315+ if n_valid != n_predictors :
316+ details += plural (" ({number} failed)" , n_predictors - n_valid )
317+ else :
318+ details += "\n No models"
319+ return details
320+
309321 def _invalidate_predictions (self ):
310322 for inputid , pred in list (self .predictors .items ()):
311323 self .predictors [inputid ] = pred ._replace (results = None )
@@ -560,10 +572,12 @@ def _add_regression_out_columns(slot, newmetas, newcolumns):
560572 def send_report (self ):
561573 def merge_data_with_predictions ():
562574 data_model = self .dataview .model ()
563- predictions_model = self .predictionsview .model ()
575+ predictions_view = self .predictionsview
576+ predictions_model = predictions_view .model ()
564577
565578 # use ItemDelegate to style prediction values
566- style = lambda x : self .predictionsview .itemDelegate ().displayText (x , QLocale ())
579+ delegates = [predictions_view .itemDelegateForColumn (i )
580+ for i in range (predictions_model .columnCount ())]
567581
568582 # iterate only over visible columns of data's QTableView
569583 iter_data_cols = list (filter (lambda x : not self .dataview .isColumnHidden (x ),
@@ -579,13 +593,15 @@ def merge_data_with_predictions():
579593 # print data & predictions
580594 for i in range (data_model .rowCount ()):
581595 yield [data_model .headerData (i , Qt .Vertical , Qt .DisplayRole )] + \
582- [style (predictions_model .data (predictions_model .index (i , j )))
583- for j in range (predictions_model .columnCount ())] + \
596+ [delegate .displayText (
597+ predictions_model .data (predictions_model .index (i , j )),
598+ QLocale ())
599+ for j , delegate in enumerate (delegates )] + \
584600 [data_model .data (data_model .index (i , j ))
585601 for j in iter_data_cols ]
586602
587603 if self .data :
588- text = self .infolabel . text ().replace ('\n ' , '<br>' )
604+ text = self ._get_details ().replace ('\n ' , '<br>' )
589605 if self .selected_classes :
590606 text += '<br>Showing probabilities for: '
591607 text += ', ' . join ([self .class_values [i ]
@@ -594,6 +610,8 @@ def merge_data_with_predictions():
594610 self .report_table ("Data & Predictions" , merge_data_with_predictions (),
595611 header_rows = 1 , header_columns = 1 )
596612
613+ self .report_table ("Scores" , self .score_table .view )
614+
597615 def resizeEvent (self , event ):
598616 super ().resizeEvent (event )
599617 self ._update_splitter ()
0 commit comments