Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Fsx script not working

Aperta
#985 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
fsharp

Direzione di ricerca

Inizia eseguendo lo script .fsx fornito e analizza il fallimento in LoadFromEnumerable nel trace di Project.fsproj.fsx, in particolare il membro option Price di F#. Determina se gli script .fsx sono supportati per questo esempio e se l’errore di tipo IDataView segnalato è previsto; il lavoro è completato quando è disponibile una diagnosi confermata e l’esempio funziona oppure la limitazione è documentata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
PowerShell
Stelle
4.7k
Fork
2.7k
Merge medio
2g 22h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/machinelearning-samples

Tutte le issue di dotnet/machinelearning-samples

Issue simili

Altre issue su Machine Learning

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.