简体   繁体   中英

System.InvalidOperationException: 'All instances skipped due to missing features.' Is the error coming from the dataset or the code?

I'm trying to learn ML.Net and C# for a school problem, tried to find similar questions but none of them solved my problem.

How can I fix this problem?

Is the error coming from the dataset or the code?

class ML_BankModel
    {
        static readonly string _dataPath = Path.Combine(Environment.CurrentDirectory, "BankDataSet", "Churn_Modelling.csv");
        static readonly string _modelPath = Path.Combine(Environment.CurrentDirectory, "BankDataSet", "Churn_Modelling.csv");
        static void Main(string[] args)
        {
            var mlContext = new MLContext();

            var trainData = mlContext.Data.LoadFromTextFile<AccountBankModel>(path: _dataPath,
                separatorChar: ',',
                hasHeader: true
                );

            var estimator = mlContext.Transforms.Conversion.ConvertType(outputColumnName: "Label", inputColumnName: "Target", DataKind.Boolean)
                .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "GeographyEncoded", inputColumnName: "Geography"))
                .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "GenderEncoded", inputColumnName: "Gender"))
                .Append(mlContext.BinaryClassification.Trainers.FastTree())
                .Append(mlContext.Transforms.Conversion.ConvertType(outputColumnName: "PredictedLabel", inputColumnName: "Label", DataKind.Boolean));

            var dataPreview = trainData.Preview();

            var transformationPreview = estimator.Preview(trainData);
        }

class AccountBankModel
    {
        [LoadColumn(2)]
        public int CustomerId { get; set; }

        [LoadColumn(4)]
        public float CreditScore { get; set; }

        [LoadColumn(5)]
        public string Geography { get; set; }
        
        [LoadColumn(6)]
        public string Gender { get; set; }

        [LoadColumn(7, 12), ColumnName("Features")]
        public float FeatureVector { get; set; }

        [LoadColumn(13)]
        public float Target { get; set; }
    }

错误

数据集样本

The problem was the dataset, after making an alteration and saving it everything is running fine. The alteration was change the 'Exited' to something else and reverting it again to 'Exited'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM