dotnet / dotnet/machinelearning-samples
Fsx script not working
- Langage dominant
- PowerShell
- Étoiles
- 4.7k
- Forks
- 2.7k
- Merge moyen
- 2 j 22 h
- PR mergées (30 j)
- 1
Description
Is .fsx not supported ?
I can't reproduce the simple demo in F# script , this doesnt seem to work
```fsharp
#r "nuget: Microsoft.ML"
open Microsoft.ML
open Microsoft.ML.Data
[]
type HouseData =
{ [] Size: float32
[] Price: float32 option }
[]
type Prediction =
{ [] 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(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 .$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
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par exécuter le script .fsx fourni et inspectez l’échec au niveau de LoadFromEnumerable dans la trace de Project.fsproj.fsx, en particulier le membre d’option Price de F#. Déterminez si les scripts .fsx sont pris en charge pour cet exemple et si l’erreur de type IDataView signalée est attendue ; le travail est terminé lorsqu’un diagnostic confirmé est établi et que l’exemple fonctionne ou que la limitation est documentée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- fsharp
- Domaine
- machine-learning
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100