在ML.NET中进行LogisticRegression预测时出现编译错误

时间:2018-12-29 15:51:12

标签: c# logistic-regression ml.net

使用Titanic数据集在ML.NET中创建Logistic回归模型。我执行了大部分代码,但是当我尝试在估算器中创建预测时,会出现编译错误。

这是完整的代码:

j8=00000001
git update-index --add --cacheinfo 160000,$j8$j8$j8$j8$j8,path/to/emptydir

此行中发生错误-var context = new MLContext(); var reader = TextLoader.CreateReader(context, ctx => ( PassengerId: ctx.LoadFloat(0), HasSurvived: ctx.LoadBool(1), PClass: ctx.LoadFloat(2), Name: ctx.LoadText(3), Gender: ctx.LoadText(4), Age: ctx.LoadFloat(5), NumOfSiblingsOrSpouses: ctx.LoadFloat(6), NumOfParentOrChildAboard: ctx.LoadFloat(7), Ticket: ctx.LoadText(8), Fare: ctx.LoadFloat(9), Cabin: ctx.LoadText(10), EmbarkedPort: ctx.LoadText(11) ), hasHeader: true, separator: ','); var data = reader.Read("titanic.csv"); var (trainData, testData) = context.BinaryClassification.TrainTestSplit(data, testFraction: 0.2); var pipeline = reader.MakeNewEstimator() .Append(row => ( Target: row.HasSurvived, Features: row.NumOfParentOrChildAboard.ConcatWith( row.NumOfSiblingsOrSpouses, row.PClass, row.Age.ReplaceNaNValues(MissingValueReplacingTransformer.ColumnInfo.ReplacementMode.Mean) ))); pipeline.Append(row => ( row.Target, Prediction: context.BinaryClassification.Trainers.LogisticRegression(row.Target, row.Features) )); context.BinaryClassification.Trainers.LogisticRegression(row.Target, row.Features)

当我将参数更改为字符串时,出现了另一个错误:cannot convert from 'Microsoft.ML.StaticPipe.Scalar<bool>' to 'string'

任何人都可以看到我在做这些错误时在做什么,或者如果我错过了下一步吗?

0 个答案:

没有答案