我是F#/ .NET的新手,我正在尝试运行如何将介绍ML.Net演示转换为F#的接受答案中提供的F#示例?使用ML.NET库,在Visual Studio上使用F#,使用Microsoft.ML(0.2.0).
在构建它时,我得到了错误 error FS0039: The type 'TextLoader' is not defined.
为了避免这种情况,我添加了这一行
open Microsoft.ML.Data
Run Code Online (Sandbox Code Playgroud)
来源.然而,然而,线
pipeline.Add(new TextLoader<IrisData>(dataPath,separator = ","))
Run Code Online (Sandbox Code Playgroud)
触发:
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 = ","))
Run Code Online (Sandbox Code Playgroud)
收益率:
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))
Run Code Online (Sandbox Code Playgroud)
使构建成功,但代码在运行时失败
ArgumentOutOfRangeException: Column #1 not found in the dataset (it only has 1 columns)
,我假设因为没有正确选取逗号分隔符(顺便说一句,您可以在https://archive.ics.uci.edu/ml/找到并检查虹膜数据集机器学习数据库/ iris/iris.data).
也
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
Run Code Online (Sandbox Code Playgroud)
不行.
我知道TextLoader
最近有变化(例如https://github.com/dotnet/machinelearning/issues/332),有人能指出我做错了吗?
F#只是有一些不同的语法,可能需要一些时间来习惯.它不使用new
关键字来实例化新类,并且使用命名参数,=
而不是使用:
C#中的参数.
所以对于C#中的这一行:
pipeline.Add(new TextLoader(dataPath).CreateFrom<IrisData>(separator: ','))
Run Code Online (Sandbox Code Playgroud)
它将在F#中出现:
pipeline.Add(TextLoader(dataPath).CreateFrom<IrisData>(separator=','))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
484 次 |
最近记录: |