CrossValidate引发错误System.ArgumentOutOfRangeException:'未找到得分列'得分'参数名称:name'

时间:2019-01-01 20:24:20

标签: ml.net

我正在跟踪GitHubLabeler结果引发异常: System.ArgumentOutOfRangeException:未找到'得分列'得分' 参数名称:名称' 呼叫

时发生错误
mlContext.MulticlassClassification.CrossValidate(...)

我知道是要它,但是GitHubLabeler没有提供它。
enter image description here

我已经修改了要从List加载的代码,其中T是具有几个hundread浮点值的ViewModel,我的实现如下:

var trainData = mlContext.CreateStreamingDataView(data);
var features = trainData.Schema.GetColumns()
    .Select(tuple => tuple.column.Name)
    .Where(name => name != labelName)
    .ToArray();


var trainingPipeline = mlContext.Transforms.Conversion.MapValueToKey(labelName, "Label")
                        .Append(mlContext.Transforms.Concatenate("Features", features))
                        .AppendCacheCheckpoint(mlContext);

IEstimator<ITransformer> trainer = null;
var selectedStrategy = MachineLearningMethods.OVAAveragedPerceptronTrainer;
switch (selectedStrategy)
{
    case MachineLearningMethods.SdcaMultiClassTrainer:
        trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(DefaultColumnNames.Label,
                                                                                                DefaultColumnNames.Features);
        break;
    case MachineLearningMethods.OVAAveragedPerceptronTrainer:
        {
            // Create a binary classification trainer.
            var averagedPerceptronBinaryTrainer = mlContext.BinaryClassification
                                                    .Trainers.AveragedPerceptron(DefaultColumnNames.Label,
                                                                                    DefaultColumnNames.Features,
                                                                                    numIterations: 10                                                                                            
                                                                                );

            trainer = mlContext.MulticlassClassification.Trainers.OneVersusAll(averagedPerceptronBinaryTrainer);

            break;
        }
    default:
        break;
}


trainingPipeline.Append(trainer).Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedLabel"));

Trace.WriteLine("=============== Cross-validating to get model's accuracy metrics ===============");
var crossValidationResults = mlContext.MulticlassClassification.CrossValidate(data: trainData
                                                                            , estimator: trainingPipeline
                                                                            , numFolds: 6
                                                                            , labelColumn: "Label");
PrintMulticlassClassificationFoldsAverageMetrics(trainer.ToString(), crossValidationResults);

Trace.WriteLine("=============== Training the model ===============");
var model = trainingPipeline.Fit(trainData);

1 个答案:

答案 0 :(得分:0)

该错误已由Microsoft修复,该问题不再存在。