Skip to content

Exceptions are not super helpful #3107

Closed

Description

@Ivanidzo4ka
var loader = mlContext.Data.CreateTextLoader(new TextLoader.Options()
            {
                HasHeader = true,
                Columns = new[] {
                    new TextLoader.Column("NumericFeatures", DataKind.Single, 0, 189),
                    new TextLoader.Column("CatFeatures", DataKind.String, 189, 229),
                    new TextLoader.Column("Label", DataKind.Int32, 230)
                }
            });
            var data = loader.Load("train.tsv");
            var dic = new Dictionary<int, bool>();
            dic.Add(1, true);
            dic.Add(-1, false);
            var pipeline = mlContext.Transforms.IndicateMissingValues("NumericFeatures").
                Append(mlContext.Transforms.Categorical.OneHotEncoding("CatFeatures")).
                Append(mlContext.Transforms.Concatenate("Features","NumericFeatures", "CatFeatures")).
                Append(mlContext.Transforms.Conversion.MapValue("Label", dic));
System.InvalidOperationException: 'Column 'CatFeatures' has values of Singlewhich is not the same as earlier observed type of Boolean.'

A) would be nice to have space between type and sentence.
B) this exception happened in Concat transform and only indication of that is stack trace.

Activity

  1. TomFinley commented on Mar 27, 2019

    @TomFinley
    Contributor

    Good point on the message. Related to one of the sub-items raised by #2514. I disagree however that reproducing the information already in the stack trace is the job of an exception message. The facility for telling where an exception was thrown is the stacktrace. So I don't view it as problematic that the only thing that shows where an exception was thrown is the stack trace, since that is more or less the entire purpose why the stack trace exists and is part of every exception.

  2. self-assigned this
    on Mar 27, 2019
  3. zeahmed commented on Mar 28, 2019

    @zeahmed
    Contributor

    System.InvalidOperationException: 'Column 'CatFeatures' has values of Singlewhich is not the same as earlier observed type of Boolean.'

    Do you know why it says 'Boolean' at the end?

  4. Ivanidzo4ka commented on Mar 28, 2019

    @Ivanidzo4ka
    ContributorAuthor

    Yep.
    So I have NumericFeatures which is array of floats.
    I apply IndicateMissingValues to it, and in my head I'm doing NAHandle, but in reality it just creates array of boolean indicators. Which I'm combining with cat features.

    Properly it should be IndicateMissingValues("MissingIndicator", "NumericFeatures"). TypeConversion("MissingIndicator", DataKind.Single). Concat("Features","MissingIndicator", "NumericFeatures","CatFeatures")

  5. ghost locked as resolved and limited conversation to collaborators on Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions