Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Fsx script not working

未关闭
#985 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
fsharp

调研方向

首先运行提供的 .fsx 脚本,并检查 Project.fsproj.fsx trace 中 LoadFromEnumerable 处的失败,尤其是 F# option 成员 Price。确定此示例是否支持 .fsx 脚本,以及报告的 IDataView 类型错误是否属于预期情况;完成的标准是得出确认的诊断,并且示例能够运行,或已记录该限制。

由索引模型根据 Issue 内容生成。

描述

Is .fsx not supported ?

I can't reproduce the simple demo in F# script , this doesnt seem to work

#r "nuget: Microsoft.ML"

open Microsoft.ML
open Microsoft.ML.Data

[<CLIMutable>]
type HouseData =
    { [<ColumnName("Size")>] Size: float32
      [<ColumnName("Price")>] Price: float32 option }

[<CLIMutable>]
type Prediction =
    { [<ColumnName("Score")>] Price: float32 }


let mlContext = new MLContext()

// 1. Import or create training data
let houseData = [| { Size = 1.1F; Price = Some(1.2F) };
                   { Size = 1.9F; Price = Some(2.3F) };
                   { Size = 2.8F; Price = Some(3.0F) };
                   { Size = 3.4F; Price = Some(3.7F) } |]
let trainingData = mlContext.Data.LoadFromEnumerable(houseData)

// 2. Specify data preparation and model training pipeline
let pipeline = 
    EstimatorChain()
        .Append(
            mlContext.Transforms.Concatenate("Features", [| "Size" |])
        )
        .Append(
            mlContext.Regression.Trainers
                .Sdca(labelColumnName = "Price", maximumNumberOfIterations = 100)
        )

// 3. Train model
let model = pipeline.Fit(trainingData)

// 4. Make a prediction
let size = { Size = 2.5F  ; Price = None }

let predictionFunc = 
    mlContext.Model.CreatePredictionEngine<HouseData, Prediction>(model)

let price = predictionFunc.Predict(size)

printfn "Predicted price for size: %f sq ft= %f" (size.Size * 1000.0F) (price.Price * 100.0F)
// Predicted price for size: 2500.0 sq ft= 261.979980

here is the error

/Users/admin/.packagemanagement/nuget/Projects/54657--8671ee2c-1953-4d65-be3f-818b53cc0f76/Project.fsproj : warning NU1701: Package 'System.Xml.Linq 3.5.21022.801' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net7.0'. This package may not be fully compatible with your project.
/Users/admin/.packagemanagement/nuget/Projects/54657--8671ee2c-1953-4d65-be3f-818b53cc0f76/Project.fsproj : warning NU1701: Package 'System.Xml.Linq 3.5.21022.801' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net7.0'. This package may not be fully compatible with your project.
[Loading /Users/admin/.packagemanagement/nuget/Projects/54657--8671ee2c-1953-4d65-be3f-818b53cc0f76/Project.fsproj.fsx]
module FSI_0015.Project.fsproj

System.ArgumentOutOfRangeException: Could not determine an IDataView type and registered custom types for member Price@ (Parameter 'rawType')
   at Microsoft.ML.Data.InternalSchemaDefinition.GetVectorAndItemType(String name, Type rawType, IEnumerable`1 attributes, Boolean& isVector, Type& itemType)
   at Microsoft.ML.Data.InternalSchemaDefinition.GetVectorAndItemType(MemberInfo memberInfo, Boolean& isVector, Type& itemType)
   at Microsoft.ML.Data.SchemaDefinition.Create(Type userType, Direction direction)
   at Microsoft.ML.Data.InternalSchemaDefinition.Create(Type userType, Direction direction)
   at Microsoft.ML.Data.DataViewConstructionUtils.CreateFromEnumerable[TRow](IHostEnvironment env, IEnumerable`1 data, SchemaDefinition schemaDefinition)
   at Microsoft.ML.DataOperationsCatalog.LoadFromEnumerable[TRow](IEnumerable`1 data, SchemaDefinition schemaDefinition)
   at <StartupCode$FSI_0016>.$FSI_0016.main@() in /Users/admin/Repositories/scripts/mlanonimizer.fsx:line 380
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Stopped due to error
主要语言
PowerShell
星标
4.7k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/machinelearning-samples 的其他 Issue

查看 dotnet/machinelearning-samples 的全部 Issue

相似的 Issue

更多 Machine Learning Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。