Skip to content
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

ColumnNameAttribute not working for TextLoader #997

Closed
feiyun0112 opened this issue Sep 24, 2018 · 0 comments
Closed

ColumnNameAttribute not working for TextLoader #997

feiyun0112 opened this issue Sep 24, 2018 · 0 comments

Comments

@feiyun0112
Copy link
Contributor

Issue

ML.NET Tutorial define IrisData class like this:

       public class IrisData
        {
            [Column("0")]
            public float SepalLength;

            [Column("1")]
            public float SepalWidth;

            [Column("2")]
            public float PetalLength;

            [Column("3")]
            public float PetalWidth;

            [Column("4")]
            [ColumnName("Label")]
            public string Label;
        }

If I changed field name from Label to other name(like Label_1)

        public class IrisData
        {
            [Column("0")]
            public float SepalLength;

            [Column("1")]
            public float SepalWidth;

            [Column("2")]
            public float PetalLength;

            [Column("3")]
            public float PetalWidth;

            [Column("4")]
            [ColumnName("Label")]
            public string Label_1;
        }

It will throw Exception(Source column 'Label' not found):

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Private.CoreLib.dll: 'Exception has been thrown by the target of an invocation.'
 Inner exceptions found, see $exception in variables window for more details.
 Innermost exception 	 System.ArgumentOutOfRangeException : Source column 'Label' not found
   at Microsoft.ML.Runtime.Data.OneToOneTransformBase.Bindings.Create(OneToOneTransformBase parent, OneToOneColumn[] column, ISchema input, ITransposeSchema transInput, Func`2 testType)
   at Microsoft.ML.Runtime.Data.OneToOneTransformBase..ctor(IHostEnvironment env, String name, OneToOneColumn[] column, IDataView input, Func`2 testType)
   at Microsoft.ML.Runtime.Data.TermTransform..ctor(ArgumentsBase args, ColumnBase[] column, IHostEnvironment env, IDataView input)
   at Microsoft.ML.Runtime.Transforms.TextAnalytics.TermTransform(IHostEnvironment env, Arguments input)

Fix

It can be fixed by setting name in ColumnAttribute

[Column("4","Label")]            
public string Label_1;
@Zruty0 Zruty0 closed this as completed in 655c2e2 Sep 25, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 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

No branches or pull requests

1 participant