diff --git a/src/Microsoft.Data.Analysis/DataFrame.cs b/src/Microsoft.Data.Analysis/DataFrame.cs index 8eb04797aa..bd8ebfcfaa 100644 --- a/src/Microsoft.Data.Analysis/DataFrame.cs +++ b/src/Microsoft.Data.Analysis/DataFrame.cs @@ -514,7 +514,7 @@ public DataFrame Append(IEnumerable row = null, bool inPlace = false) value = Convert.ChangeType(value, column.DataType); if (value is null) { - throw new ArgumentException(string.Format(Strings.MismatchedValueType, column.DataType), value.GetType().ToString()); + throw new ArgumentException(string.Format(Strings.MismatchedValueType, column.DataType), column.Name); } } cachedObjectConversions.Add(value); @@ -583,7 +583,7 @@ public DataFrame Append(IEnumerable> row, bool inPl value = Convert.ChangeType(value, column.DataType); if (value is null) { - throw new ArgumentException(string.Format(Strings.MismatchedValueType, column.DataType), value.GetType().ToString()); + throw new ArgumentException(string.Format(Strings.MismatchedValueType, column.DataType), column.Name); } } cachedObjectConversions.Add(value); diff --git a/src/Microsoft.ML.Data/Evaluators/MultiOutputRegressionEvaluator.cs b/src/Microsoft.ML.Data/Evaluators/MultiOutputRegressionEvaluator.cs index 8841bc44e5..42078a0786 100644 --- a/src/Microsoft.ML.Data/Evaluators/MultiOutputRegressionEvaluator.cs +++ b/src/Microsoft.ML.Data/Evaluators/MultiOutputRegressionEvaluator.cs @@ -60,11 +60,11 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema) var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score); var t = score.Type as VectorDataViewType; if (t == null || !t.IsKnownSize || t.ItemType != NumberDataViewType.Single) - throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of Single", t.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "known-size vector of Single", score.Type.ToString()); Host.Check(schema.Label.HasValue, "Could not find the label column"); t = schema.Label.Value.Type as VectorDataViewType; if (t == null || !t.IsKnownSize || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double)) - throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "known-size vector of Single or Double", t.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "label", schema.Label.Value.Name, "known-size vector of Single or Double", schema.Label.Value.Type.ToString()); } private protected override Aggregator GetAggregatorCore(RoleMappedSchema schema, string stratName) @@ -548,7 +548,7 @@ private void CheckInputColumnTypes(DataViewSchema schema, out VectorDataViewType var t = schema[LabelIndex].Type as VectorDataViewType; if (t == null || !t.IsKnownSize || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double)) - throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "known-size vector of Single or Double", t.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "known-size vector of Single or Double", schema[LabelIndex].Type.ToString()); labelType = new VectorDataViewType((PrimitiveDataViewType)t.ItemType, t.Size); var slotNamesType = new VectorDataViewType(TextDataViewType.Instance, t.Size); var builder = new DataViewSchema.Annotations.Builder(); @@ -557,7 +557,7 @@ private void CheckInputColumnTypes(DataViewSchema schema, out VectorDataViewType t = schema[ScoreIndex].Type as VectorDataViewType; if (t == null || !t.IsKnownSize || t.ItemType != NumberDataViewType.Single) - throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of Single", t.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "known-size vector of Single", schema[ScoreIndex].Type.ToString()); scoreType = new VectorDataViewType((PrimitiveDataViewType)t.ItemType, t.Size); builder = new DataViewSchema.Annotations.Builder(); builder.AddSlotNames(t.Size, CreateSlotNamesGetter(schema, ScoreIndex, scoreType.Size, "Predicted")); diff --git a/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs b/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs index f084867b96..ecdc2509cc 100644 --- a/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs +++ b/src/Microsoft.ML.Data/Evaluators/MulticlassClassificationEvaluator.cs @@ -77,7 +77,7 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema) var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score); var scoreType = score.Type as VectorDataViewType; if (scoreType == null || scoreType.Size < 2 || scoreType.ItemType != NumberDataViewType.Single) - throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "vector of two or more items of type Single", scoreType.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "vector of two or more items of type Single", score.Type.ToString()); Host.CheckParam(schema.Label.HasValue, nameof(schema), "Could not find the label column"); var labelType = schema.Label.Value.Type; if (labelType != NumberDataViewType.Single && labelType.GetKeyCount() <= 0) @@ -859,7 +859,7 @@ private void CheckInputColumnTypes(DataViewSchema schema) var scoreType = schema[ScoreIndex].Type as VectorDataViewType; if (scoreType == null || scoreType.Size < 2 || scoreType.ItemType != NumberDataViewType.Single) - throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "Vector of two or more items of type Single", scoreType.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "score", ScoreCol, "Vector of two or more items of type Single", schema[ScoreIndex].Type.ToString()); var labelType = schema[LabelIndex].Type; if (labelType != NumberDataViewType.Single && labelType.GetKeyCount() <= 0) throw Host.ExceptSchemaMismatch(nameof(schema), "label", LabelCol, "Single or Key", labelType.ToString()); diff --git a/src/Microsoft.ML.Data/Evaluators/QuantileRegressionEvaluator.cs b/src/Microsoft.ML.Data/Evaluators/QuantileRegressionEvaluator.cs index d32d88bd42..53410ce4e5 100644 --- a/src/Microsoft.ML.Data/Evaluators/QuantileRegressionEvaluator.cs +++ b/src/Microsoft.ML.Data/Evaluators/QuantileRegressionEvaluator.cs @@ -58,7 +58,7 @@ private protected override void CheckScoreAndLabelTypes(RoleMappedSchema schema) var score = schema.GetUniqueColumn(AnnotationUtils.Const.ScoreValueKind.Score); var t = score.Type as VectorDataViewType; if (t == null || t.Size == 0 || (t.ItemType != NumberDataViewType.Single && t.ItemType != NumberDataViewType.Double)) - throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Vector of Single or Double", t.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "score", score.Name, "Vector of Single or Double", score.Type.ToString()); Host.CheckParam(schema.Label.HasValue, nameof(schema), "Must contain a label column"); var labelType = schema.Label.Value.Type; if (labelType != NumberDataViewType.Single) diff --git a/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs b/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs index 87b8ff18a0..e4de14b814 100644 --- a/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs +++ b/src/Microsoft.ML.Data/Transforms/FeatureContributionCalculationTransformer.cs @@ -182,7 +182,7 @@ public Mapper(FeatureContributionCalculatingTransformer parent, DataViewSchema s throw Host.ExceptSchemaMismatch(nameof(schema), "input", _parent.ColumnPairs[0].inputColumnName); _featureColumnType = schema[_featureColumnIndex].Type as VectorDataViewType; if (_featureColumnType == null || _featureColumnType.ItemType != NumberDataViewType.Single) - throw Host.ExceptSchemaMismatch(nameof(schema), "feature", _parent.ColumnPairs[0].inputColumnName, "vector of Single", _featureColumnType.ItemType.ToString()); + throw Host.ExceptSchemaMismatch(nameof(schema), "feature", _parent.ColumnPairs[0].inputColumnName, "vector of Single", schema[_featureColumnIndex].Type.ToString()); if (InputSchema[_featureColumnIndex].HasSlotNames(_featureColumnType.Size)) InputSchema[_featureColumnIndex].Annotations.GetValue(AnnotationUtils.Kinds.SlotNames, ref _slotNames);