ml.net 0.11试图预测数字的数组/序列-标签列''的模式不匹配:预期为R4,得到了Vector <r4>参数名称:labelCol'

时间:2019-04-03 20:20:56

标签: vb.net vector ml.net

我正在尝试返回数字数组的预测/标签,但标签列“”的模式不匹配:预期为R4,得到了矢量 参数名称:labelCol'错误。任何想法我做错了什么。

我在Visual Studio 2017中使用ml.net 0.11。 我从可枚举中加载数据并将其传递到管道。 对于一个值,它工作正常,但是当我更改为输出到vector时,我得到了错误。

类结构为

Public Class BallsDrawn
    <LoadColumn(0)>
    <ColumnName("Sequence")>
    Public Sequence As Single

    <LoadColumn(1)>
    <ColumnName("Day")>
    Public Day As Single

    <LoadColumn(2)>
    <ColumnName("Month")>
    Public Month As Single

    <LoadColumn(3)>
    <ColumnName("Year")>
    Public Year As Single

    <LoadColumn(4)>
    <ColumnName("Balls")>
    <VectorType(8)>
    Public Balls() As Single

End Class

Public Class BallsDrawnPrediction



    <ColumnName("Score")>
    <VectorType(8)>
    Public Balls() As Single


End Class

'代码以加载数据工作正常。  testDataView = mlContext.Data.LoadFromEnumerable((GetTestDataList(records,5)))

'管道

        Dim dataProcessPipeline = mlContext.Transforms.Conversion.MapValueToKey(outputColumnName:=DefaultColumnNames.Label, inputColumnName:=NameOf(MLnet.BallsDrawn.Balls)).Append(mlContext.Transforms.CopyColumns(outputColumnName:=DefaultColumnNames.Label, inputColumnName:=NameOf(MLnet.BallsDrawn.Balls))).Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName:="Sequence", inputColumnName:=NameOf(MLnet.BallsDrawn.Sequence))).Append(mlContext.Transforms.Normalize(outputColumnName:=NameOf(BallsDrawn.Day), mode:=NormalizerMode.MeanVariance)).Append(mlContext.Transforms.Normalize(outputColumnName:=NameOf(BallsDrawn.Month), mode:=NormalizerMode.MeanVariance)).Append(mlContext.Transforms.Normalize(outputColumnName:=NameOf(BallsDrawn.Year), mode:=NormalizerMode.MeanVariance)).Append(mlContext.Transforms.Concatenate(DefaultColumnNames.Features, "Sequence", NameOf(MLnet.BallsDrawn.Day), NameOf(MLnet.BallsDrawn.Month), NameOf(MLnet.BallsDrawn.Year))).AppendCacheCheckpoint(mlContext)

'测试多位培训师

 Dim trainer As IEstimator(Of ITransformer)

        Select Case Learner
          '  Case = Learner.FastTree
              '  trainer = mlContext.Ranking.Trainers.FastTree(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

          '  Case = Learner.FastTreeTweedie
              '  trainer = mlContext.Regression.Trainers.FastTreeTweedie(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

            Case = Learner.Poisson
                trainer = mlContext.Regression.Trainers.PoissonRegression(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

            Case = Learner.SDCA
                'mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent
                '  trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)
                ' trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

                trainer = mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)
                '     Case = Learner.FastForestRegressor

              '  trainer = mlContext.Regression.Trainers.FastForest(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

                '  Case = Learner.GeneralizedAdditiveModels

              '  trainer = mlContext.Regression.Trainers.GeneralizedAdditiveModels(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

            Case = Learner.OnlineGradientDescentRegressor

                trainer = mlContext.Regression.Trainers.OnlineGradientDescent(labelColumnName:=DefaultColumnNames.Label, featureColumnName:=DefaultColumnNames.Features)

                '  mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent

        End Select




        Dim trainingPipeline = dataProcessPipeline.Append(trainer)

        ' STEP 4: Train the model fitting to the DataSet
        'The pipeline is trained on the dataset that has been loaded and transformed.
        '  Console.WriteLine("=============== Training the model ===============")

'在此处获取错误。             昏暗的训练模型= trainingPipeline.Fit(trainingDataView)

试图获取一个数组或多个数字输出。 任何帮助或建议将不胜感激。

0 个答案:

没有答案