当 运行 F# 中的 ML.Net Iris 演示时,我使用 TextLoader 是不是错了?
Am I using TextLoader wrong when running the ML.Net Iris demo in F#?
我是 F#/.NET 的新手,我正在尝试 运行 with the ML.NET library 的已接受答案中提供的 F# 示例,在 Visual Studio 上使用 F#,使用 Microsoft.ML (0.2.0).
构建时出现错误 error FS0039: The type 'TextLoader' is not defined.
为了避免这种情况,我添加了行
open Microsoft.ML.Data
来源。
然而,行
pipeline.Add(new TextLoader<IrisData>(dataPath,separator = ","))
触发器:
error FS0033: The non-generic type 'Microsoft.ML.Data.TextLoader' does not expect any type arguments, but here is given 1 type argument(s)
更改为:
pipeline.Add(new TextLoader(dataPath,separator = ","))
产量:
error FS0495: The object constructor 'TextLoader' has no argument or settable return property 'separator'. The required signature is TextLoader(filePath: string) : TextLoader.
更改为:
pipeline.Add(new TextLoader(dataPath))
使构建成功,但代码在运行时失败
ArgumentOutOfRangeException: Column #1 not found in the dataset (it only has 1 columns)
,我假设是因为没有正确选择逗号分隔符(顺便说一句,您可以在 https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data 找到并检查 iris 数据集)。
还有
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
不行。
我知道 TextLoader
最近发生了变化(参见 https://github.com/dotnet/machinelearning/issues/332),有人能指出我做错了什么吗?
F# 只是有一些不同的语法,需要一些时间来适应。它不使用 new
关键字来实例化新的 class 并使用命名参数,它使用 =
而不是 C# 中的 :
。
因此对于 C# 中的这一行:
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
在 F# 中是这样的:
pipeline.Add(TextLoader(dataPath).CreateFrom<IrisData>(separator=','))
我是 F#/.NET 的新手,我正在尝试 运行
构建时出现错误 error FS0039: The type 'TextLoader' is not defined.
为了避免这种情况,我添加了行
open Microsoft.ML.Data
来源。 然而,行
pipeline.Add(new TextLoader<IrisData>(dataPath,separator = ","))
触发器:
error FS0033: The non-generic type 'Microsoft.ML.Data.TextLoader' does not expect any type arguments, but here is given 1 type argument(s)
更改为:
pipeline.Add(new TextLoader(dataPath,separator = ","))
产量:
error FS0495: The object constructor 'TextLoader' has no argument or settable return property 'separator'. The required signature is TextLoader(filePath: string) : TextLoader.
更改为:
pipeline.Add(new TextLoader(dataPath))
使构建成功,但代码在运行时失败
ArgumentOutOfRangeException: Column #1 not found in the dataset (it only has 1 columns)
,我假设是因为没有正确选择逗号分隔符(顺便说一句,您可以在 https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data 找到并检查 iris 数据集)。
还有
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
不行。
我知道 TextLoader
最近发生了变化(参见 https://github.com/dotnet/machinelearning/issues/332),有人能指出我做错了什么吗?
F# 只是有一些不同的语法,需要一些时间来适应。它不使用 new
关键字来实例化新的 class 并使用命名参数,它使用 =
而不是 C# 中的 :
。
因此对于 C# 中的这一行:
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
在 F# 中是这样的:
pipeline.Add(TextLoader(dataPath).CreateFrom<IrisData>(separator=','))