我正在尝试编写一个基本的“hello world”类型程序来预测 XOR 函数的值。这是我收到的错误消息:
Unhandled Exception: System.ArgumentOutOfRangeException: Schema mismatch for feature column 'Features': expected Vector<R4>, got Vector<R8>
参数名称:inputSchema 这是我的代码:
type Sample = {
X: float
Y: float
Result: float
}
let createSample x y result = {X = x; Y = y; Result = result}
let solveXOR() =
let problem =
[
createSample 0.0 0.0 0.0
createSample 1.0 0.0 1.0
createSample 0.0 1.0 1.0
createSample 1.0 0.0 0.0
]
let context = new MLContext()
let data = context.Data.ReadFromEnumerable(problem)
let pipeline =
context.Transforms
.Concatenate("Features", "X", "Y")
.Append(context.Transforms.CopyColumns(inputColumnName = "Result", outputColumnName = "Label"))
//.Append(context.Transforms.Conversion.MapKeyToVector("X"))
//.Append(context.Transforms.Conversion.MapKeyToVector("Y"))
.AppendCacheCheckpoint(context)
.Append(context.Regression.Trainers.FastTree())
let model = pipeline.Fit(data)
let predictions = model.Transform(data)
let metrics = context.BinaryClassification.Evaluate(predictions)
printfn "Accuracy %f" metrics.Accuracy
任何关于我做错了什么的指针将不胜感激。