@@ -95,11 +95,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
95
95
var score = schema . GetUniqueColumn ( MetadataUtils . Const . ScoreValueKind . Score ) ;
96
96
var t = score . Type ;
97
97
if ( t != NumberType . Float )
98
- throw Host . Except ( "Score column '{0}' has type '{1}' but must be R4" , score , t ) . MarkSensitive ( MessageSensitivity . Schema ) ;
98
+ throw Host . ExceptSchemaMismatch ( nameof ( schema ) , "score" , score . Name , "float" , t . ToString ( ) ) ;
99
99
Host . Check ( schema . Label . HasValue , "Could not find the label column" ) ;
100
100
t = schema . Label . Value . Type ;
101
101
if ( t != NumberType . Float && t . GetKeyCount ( ) != 2 )
102
- throw Host . Except ( " Label column '{0}' has type '{1}' but must be R4 or a 2-value key", schema . Label . Value . Name , t ) . MarkSensitive ( MessageSensitivity . Schema ) ;
102
+ throw Host . ExceptSchemaMismatch ( nameof ( schema ) , "label" , schema . Label . Value . Name , "float or a 2-value key", t . ToString ( ) ) ;
103
103
}
104
104
105
105
private protected override Aggregator GetAggregatorCore ( RoleMappedSchema schema , string stratName )
@@ -630,13 +630,13 @@ private protected override void PrintFoldResultsCore(IChannel ch, Dictionary<str
630
630
{
631
631
int index ;
632
632
if ( ! top . Schema . TryGetColumnIndex ( AnomalyDetectionEvaluator . TopKResultsColumns . Instance , out index ) )
633
- throw Host . Except ( "Data view does not contain the ' Instance' column" ) ;
633
+ throw Host . ExceptSchemaMismatch ( nameof ( top . Schema ) , "instance" , AnomalyDetectionEvaluator . TopKResultsColumns . Instance ) ;
634
634
var instanceGetter = cursor . GetGetter < ReadOnlyMemory < char > > ( index ) ;
635
635
if ( ! top . Schema . TryGetColumnIndex ( AnomalyDetectionEvaluator . TopKResultsColumns . AnomalyScore , out index ) )
636
- throw Host . Except ( "Data view does not contain the 'Anomaly Score' column" ) ;
636
+ throw Host . ExceptSchemaMismatch ( nameof ( top . Schema ) , "anomaly score" , AnomalyDetectionEvaluator . TopKResultsColumns . AnomalyScore ) ;
637
637
var scoreGetter = cursor . GetGetter < Single > ( index ) ;
638
638
if ( ! top . Schema . TryGetColumnIndex ( AnomalyDetectionEvaluator . TopKResultsColumns . Label , out index ) )
639
- throw Host . Except ( "Data view does not contain the ' Label' column" ) ;
639
+ throw Host . ExceptSchemaMismatch ( nameof ( top . Schema ) , "label" , AnomalyDetectionEvaluator . TopKResultsColumns . Label ) ;
640
640
var labelGetter = cursor . GetGetter < Single > ( index ) ;
641
641
642
642
bool hasRows = false ;
@@ -665,12 +665,12 @@ private protected override void PrintFoldResultsCore(IChannel ch, Dictionary<str
665
665
666
666
IDataView overall ;
667
667
if ( ! metrics . TryGetValue ( MetricKinds . OverallMetrics , out overall ) )
668
- throw Host . Except ( "No overall metrics found" ) ;
668
+ throw Host . ExceptSchemaMismatch ( nameof ( overall . Schema ) , " overall metrics" , MetricKinds . OverallMetrics ) ;
669
669
670
670
// Find the number of anomalies, and the thresholds.
671
671
int numAnomIndex ;
672
672
if ( ! overall . Schema . TryGetColumnIndex ( AnomalyDetectionEvaluator . OverallMetrics . NumAnomalies , out numAnomIndex ) )
673
- throw Host . Except ( "Could not find the ' NumAnomalies' column" ) ;
673
+ throw Host . ExceptSchemaMismatch ( nameof ( overall . Schema ) , "number of anomalies" , AnomalyDetectionEvaluator . OverallMetrics . NumAnomalies ) ;
674
674
675
675
int stratCol ;
676
676
var hasStrat = overall . Schema . TryGetColumnIndex ( MetricKinds . ColumnNames . StratCol , out stratCol ) ;
0 commit comments