Skip to content

Exceptions are not super helpful #3107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ivanidzo4ka opened this issue Mar 27, 2019 · 3 comments · Fixed by #3122
Closed

Exceptions are not super helpful #3107

Ivanidzo4ka opened this issue Mar 27, 2019 · 3 comments · Fixed by #3122
Assignees

Comments

@Ivanidzo4ka
Copy link
Contributor

Ivanidzo4ka commented Mar 27, 2019

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.

@TomFinley
Copy link
Contributor

TomFinley commented Mar 27, 2019

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.

@zeahmed
Copy link
Contributor

zeahmed commented Mar 28, 2019

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?

@Ivanidzo4ka
Copy link
Contributor Author

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")

@ghost ghost locked as resolved and limited conversation to collaborators Mar 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants