Skip to content

Commit beb67a1

Browse files
authored
Attempt to fix error messages types (#3046)
1 parent f342403 commit beb67a1

File tree

143 files changed

+2510
-9094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+2510
-9094
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Transforms/ReplaceMissingValues.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public static void Example()
1313
// Create a new ML context, for ML.NET operations. It can be used for exception tracking and logging,
1414
// as well as the source of randomness.
1515
var mlContext = new MLContext();
16-
1716
var samples = new List<DataPoint>()
1817
{
1918
new DataPoint(){ Label = 3, Features = new float[3] {1, 1, 0} },

src/Microsoft.ML.Data/Data/RowCursorUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static string TestGetLabelGetter(DataViewType type, bool allowKeys)
341341
if (allowKeys && type is KeyDataViewType)
342342
return null;
343343

344-
return allowKeys ? "Expected R4, R8, Bool or Key type" : "Expected R4, R8 or Bool type";
344+
return allowKeys ? "Expected Single, Double, Boolean or Key type" : "Expected Single, Double or Boolean type";
345345
}
346346

347347
public static ValueGetter<Single> GetLabelGetter(DataViewRow cursor, int labelIndex)

src/Microsoft.ML.Data/Evaluators/AnomalyDetectionEvaluator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
9797
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
9898
var t = score.Type;
9999
if (t != NumberDataViewType.Single)
100-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "float", t.ToString());
100+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Single", t.ToString());
101101
Host.Check(schema.Label.HasValue, "Could not find the label column");
102102
t = schema.Label.Value.Type;
103103
if (t != NumberDataViewType.Single && t.GetKeyCount() != 2)
104-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "float or a KeyType with cardinality 2", t.ToString());
104+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "Single or a Key with cardinality 2", t.ToString());
105105
}
106106

107107
private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName)

src/Microsoft.ML.Data/Evaluators/BinaryClassifierEvaluator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
129129
var host = Host.SchemaSensitive();
130130
var t = score.Type;
131131
if (t != NumberDataViewType.Single)
132-
throw host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "float", t.ToString());
132+
throw host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Single", t.ToString());
133133
host.Check(schema.Label.HasValue, "Could not find the label column");
134134
t = schema.Label.Value.Type;
135135
if (t != NumberDataViewType.Single && t != NumberDataViewType.Double && t != BooleanDataViewType.Instance && t.GetKeyCount() != 2)
136-
throw host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "float, double, bool, or a KeyType with cardinality 2", t.ToString());
136+
throw host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "Single, Double, Boolean, or a Key with cardinality 2", t.ToString());
137137
}
138138

139139
private protected override void CheckCustomColumnTypesCore(RoleMappedSchema schema)
@@ -145,7 +145,7 @@ private protected override void CheckCustomColumnTypesCore(RoleMappedSchema sche
145145
host.CheckParam(prob.Count == 1, nameof(schema), "Cannot have multiple probability columns");
146146
var probType = prob[0].Type;
147147
if (probType != NumberDataViewType.Single)
148-
throw host.ExceptSchemaMismatch(nameof(schema), "probability", prob[0].Name, "float", probType.ToString());
148+
throw host.ExceptSchemaMismatch(nameof(schema), "probability", prob[0].Name, "Single", probType.ToString());
149149
}
150150
else if (!_useRaw)
151151
{
@@ -1248,18 +1248,18 @@ private void CheckInputColumnTypes(DataViewSchema schema)
12481248

12491249
var t = schema[(int)LabelIndex].Type;
12501250
if (t != NumberDataViewType.Single && t != NumberDataViewType.Double && t != BooleanDataViewType.Instance && t.GetKeyCount() != 2)
1251-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "float, double, bool or a KeyType with cardinality 2", t.ToString());
1251+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "Single, Double, Boolean or a Key with cardinality 2", t.ToString());
12521252

12531253
t = schema[ScoreIndex].Type;
12541254
if (t != NumberDataViewType.Single)
1255-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "float", t.ToString());
1255+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "Single", t.ToString());
12561256

12571257
if (_probIndex >= 0)
12581258
{
12591259
Host.Assert(!string.IsNullOrEmpty(_probCol));
12601260
t = schema[_probIndex].Type;
12611261
if (t != NumberDataViewType.Single)
1262-
throw Host.ExceptSchemaMismatch(nameof(schema), "probability", _probCol, "float", t.ToString());
1262+
throw Host.ExceptSchemaMismatch(nameof(schema), "probability", _probCol, "Single", t.ToString());
12631263
}
12641264
else if (!_useRaw)
12651265
throw Host.Except("Cannot compute the predicted label from the probability column because it does not exist");

src/Microsoft.ML.Data/Evaluators/ClusteringEvaluator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
100100
if (type != null && type != NumberDataViewType.Single && !(type is KeyDataViewType keyType && keyType.Count > 0))
101101
{
102102
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name,
103-
"float or KeyType", type.ToString());
103+
"Single or Key", type.ToString());
104104
}
105105

106106
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
107107
type = score.Type;
108108
if (!(type is VectorDataViewType vectorType) || !vectorType.IsKnownSize || vectorType.ItemType != NumberDataViewType.Single)
109-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of float", type.ToString());
109+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of Single", type.ToString());
110110
}
111111

112112
private protected override void CheckCustomColumnTypesCore(RoleMappedSchema schema)
@@ -754,7 +754,7 @@ private void CheckInputColumnTypes(DataViewSchema schema)
754754

755755
var type = schema[(int) ScoreIndex].Type;
756756
if (!(type is VectorDataViewType vectorType) || !vectorType.IsKnownSize || vectorType.ItemType != NumberDataViewType.Single)
757-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of float", type.ToString());
757+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of Single", type.ToString());
758758
}
759759
}
760760

src/Microsoft.ML.Data/Evaluators/MultiOutputRegressionEvaluator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
6060
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
6161
var t = score.Type as VectorDataViewType;
6262
if (t == null || !t.IsKnownSize || t.ItemType != NumberDataViewType.Single)
63-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of float", t.ToString());
63+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of Single", t.ToString());
6464
Host.Check(schema.Label.HasValue, "Could not find the label column");
6565
t = schema.Label.Value.Type as VectorDataViewType;
6666
if (t == null || !t.IsKnownSize || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double))
67-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "known-size vector of float or double", t.ToString());
67+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "known-size vector of Single or Double", t.ToString());
6868
}
6969

7070
private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName)
@@ -548,7 +548,7 @@ private void CheckInputColumnTypes(DataViewSchema schema, out VectorDataViewType
548548

549549
var t = schema[LabelIndex].Type as VectorDataViewType;
550550
if (t == null || !t.IsKnownSize || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double))
551-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "known-size vector of float or double", t.ToString());
551+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "known-size vector of Single or Double", t.ToString());
552552
labelType = new VectorDataViewType((PrimitiveDataViewType)t.ItemType, t.Size);
553553
var slotNamesType = new VectorDataViewType(TextDataViewType.Instance, t.Size);
554554
var builder = new DataViewSchema.Annotations.Builder();
@@ -557,7 +557,7 @@ private void CheckInputColumnTypes(DataViewSchema schema, out VectorDataViewType
557557

558558
t = schema[ScoreIndex].Type as VectorDataViewType;
559559
if (t == null || !t.IsKnownSize || t.ItemType != NumberDataViewType.Single)
560-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of float", t.ToString());
560+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of Single", t.ToString());
561561
scoreType = new VectorDataViewType((PrimitiveDataViewType)t.ItemType, t.Size);
562562
builder = new DataViewSchema.Annotations.Builder();
563563
builder.AddSlotNames(t.Size, CreateSlotNamesGetter(schema, ScoreIndex, scoreType.Size, "Predicted"));

src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
7676
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
7777
var scoreType = score.Type as VectorDataViewType;
7878
if (scoreType == null || scoreType.Size < 2 || scoreType.ItemType != NumberDataViewType.Single)
79-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "vector of two or more items of type float", scoreType.ToString());
79+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "vector of two or more items of type Single", scoreType.ToString());
8080
Host.CheckParam(schema.Label.HasValue, nameof(schema), "Could not find the label column");
8181
var labelType = schema.Label.Value.Type;
8282
if (labelType != NumberDataViewType.Single && labelType.GetKeyCount() <= 0)
83-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "float or KeyType", labelType.ToString());
83+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "Single or Key", labelType.ToString());
8484
}
8585

8686
private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName)
@@ -814,10 +814,10 @@ private void CheckInputColumnTypes(DataViewSchema schema)
814814

815815
var scoreType = schema[ScoreIndex].Type as VectorDataViewType;
816816
if (scoreType == null || scoreType.Size < 2 || scoreType.ItemType != NumberDataViewType.Single)
817-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "vector of two or more items of type float", scoreType.ToString());
817+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "Vector of two or more items of type Single", scoreType.ToString());
818818
var labelType = schema[LabelIndex].Type;
819819
if (labelType != NumberDataViewType.Single && labelType.GetKeyCount() <= 0)
820-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "float or KeyType", labelType.ToString());
820+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "Single or Key", labelType.ToString());
821821
}
822822
}
823823

src/Microsoft.ML.Data/Evaluators/QuantileRegressionEvaluator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
5858
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
5959
var t = score.Type as VectorDataViewType;
6060
if (t == null || t.Size == 0 || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double))
61-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "vector of float or double", t.ToString());
61+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Vector of Single or Double", t.ToString());
6262
Host.CheckParam(schema.Label.HasValue, nameof(schema), "Must contain a label column");
6363
var labelType = schema.Label.Value.Type;
6464
if (labelType != NumberDataViewType.Single)
65-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "float", t.ToString());
65+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "Single", t.ToString());
6666
}
6767

6868
private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName)
@@ -446,12 +446,12 @@ private void CheckInputColumnTypes(DataViewSchema schema)
446446

447447
var t = schema[(int)LabelIndex].Type;
448448
if (t != NumberDataViewType.Single)
449-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "float", t.ToString());
449+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "Single", t.ToString());
450450

451451
VectorDataViewType scoreType = schema[ScoreIndex].Type as VectorDataViewType;
452452
if (scoreType == null || scoreType.Size == 0 || (scoreType.ItemType != NumberDataViewType.Single && scoreType.ItemType != NumberDataViewType.Double))
453453
{
454-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of float or double", t.ToString());
454+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of Single or Double", t.ToString());
455455

456456
}
457457
}

src/Microsoft.ML.Data/Evaluators/RankingEvaluator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
8989
if (t != NumberDataViewType.Single && !(t is KeyDataViewType))
9090
{
9191
throw Host.ExceptSchemaMismatch(nameof(RankingMamlEvaluator.Arguments.LabelColumn),
92-
"label", schema.Label.Value.Name, "R4 or a key", t.ToString());
92+
"label", schema.Label.Value.Name, "Single or a Key", t.ToString());
9393
}
9494
var scoreCol = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
9595
if (scoreCol.Type != NumberDataViewType.Single)
9696
{
9797
throw Host.ExceptSchemaMismatch(nameof(RankingMamlEvaluator.Arguments.ScoreColumn),
98-
"score", scoreCol.Name, "R4", t.ToString());
98+
"score", scoreCol.Name, "Single", t.ToString());
9999
}
100100
}
101101

@@ -105,7 +105,7 @@ private protected override void CheckCustomColumnTypesCore(RoleMappedSchema sche
105105
if (!(t is KeyDataViewType))
106106
{
107107
throw Host.ExceptSchemaMismatch(nameof(RankingMamlEvaluator.Arguments.GroupIdColumn),
108-
"group", schema.Group.Value.Name, "key", t.ToString());
108+
"group", schema.Group.Value.Name, "Key", t.ToString());
109109
}
110110
}
111111

src/Microsoft.ML.Data/Evaluators/RegressionEvaluator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema)
5757
var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score);
5858
var t = score.Type;
5959
if (t != NumberDataViewType.Single)
60-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "float", t.ToString());
60+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Single", t.ToString());
6161
Host.CheckParam(schema.Label.HasValue, nameof(schema), "Could not find the label column");
6262
t = schema.Label.Value.Type;
6363
if (t != NumberDataViewType.Single)
64-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "float", t.ToString());
64+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "Single", t.ToString());
6565
}
6666

6767
private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName)
@@ -319,11 +319,11 @@ private void CheckInputColumnTypes(DataViewSchema schema)
319319

320320
var t = schema[(int)LabelIndex].Type;
321321
if (t != NumberDataViewType.Single)
322-
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "float", t.ToString());
322+
throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "Single", t.ToString());
323323

324324
t = schema[ScoreIndex].Type;
325325
if (t != NumberDataViewType.Single)
326-
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "float", t.ToString());
326+
throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "Single", t.ToString());
327327
}
328328
}
329329

src/Microsoft.ML.Data/Training/TrainerUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static void CheckBinaryLabel(this RoleMappedData data)
106106
}
107107
}
108108
throw Contracts.ExceptParam(nameof(data),
109-
"The label column '{0}' of the training data has a data type not suitable for binary classification: {1}. Type must be Bool, R4, R8 or Key with two classes.",
109+
"The label column '{0}' of the training data has a data type not suitable for binary classification: {1}. Type must be Boolean, Single, Double or Key with two classes.",
110110
col.Name, col.Type);
111111
}
112112
}
@@ -125,7 +125,7 @@ public static void CheckRegressionLabel(this RoleMappedData data)
125125
if (col.Type != NumberDataViewType.Single && col.Type != NumberDataViewType.Double)
126126
{
127127
throw Contracts.ExceptParam(nameof(data),
128-
"Training label column '{0}' type isn't suitable for regression: {1}. Type must be R4 or R8.", col.Name, col.Type);
128+
"Training label column '{0}' type isn't suitable for regression: {1}. Type must be Single or Double.", col.Name, col.Type);
129129
}
130130
}
131131

@@ -152,7 +152,7 @@ public static void CheckMulticlassLabel(this RoleMappedData data, out int count)
152152

153153
// REVIEW: Support other numeric types.
154154
if (col.Type != NumberDataViewType.Single && col.Type != NumberDataViewType.Double)
155-
throw Contracts.ExceptParam(nameof(data), "Training label column '{0}' type is not valid for multi-class: {1}. Type must be R4 or R8.", col.Name, col.Type);
155+
throw Contracts.ExceptParam(nameof(data), "Training label column '{0}' type is not valid for multi-class: {1}. Type must be Single or Double.", col.Name, col.Type);
156156

157157
int max = -1;
158158
using (var cursor = new FloatLabelCursor(data))
@@ -193,7 +193,7 @@ public static void CheckMultiOutputRegressionLabel(this RoleMappedData data)
193193
if (!(col.Type is VectorDataViewType vectorType
194194
&& vectorType.IsKnownSize
195195
&& vectorType.ItemType == NumberDataViewType.Single))
196-
throw Contracts.ExceptParam(nameof(data), "Training label column '{0}' must be a known-size vector of R4, but has type: {1}.", col.Name, col.Type);
196+
throw Contracts.ExceptParam(nameof(data), "Training label column '{0}' must be a known-size vector of Single, but has type: {1}.", col.Name, col.Type);
197197
}
198198

199199
public static void CheckOptFloatWeight(this RoleMappedData data)

0 commit comments

Comments
 (0)