dotnet / dotnet/machinelearning
Can't use LoadFromEnumerable in F#
- Dominant language
- C#
- Stars
- 9.4k
- Forks
- 2k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 11
Description
Using a BinaryClassifier, with AutoML in F#, I have my data structured at this type:
myData: float32 array list
So, each row is a float32 array and I've a list of rows.
The first column is the label, all other columns are the features
Using context.Data.LoadFromEnumerable () does not work on this data type.
While the list implements IEnumerable, I can't use that function.
For now, I'm using something very ugly: I write the data to a csv and I load it from disk:
the row is defined as:
```
[]
type DataRow =
{
[]
Label: bool
[]
Features: float32 array
}
```
which makes very little sense...
and the loading code is even worse:
```
let trainModel (l: float32 array list) =
// create the MLContext
let context = MLContext()
// add logging
context.Log.Add (fun m -> if m.Kind <> ChannelMessageKind.Trace then info m.RawMessage)
// build a filename
let filename = nanoGuid()
// build the data as text
let text =
l
|> List.map (fun r -> r |> Array.map string |> String.concat ",")
|> String.concat "\n"
// write it to a file
File.WriteAllText(filename, text)
// load the data
let loadedData = context.Data.LoadFromTextFile (filename, hasHeader = false, separatorChar = ',')
// shuffle the data
let shuffledData = context.Data.ShuffleRows (loadedData)
```
how can I use LoadFromEnumerable from a list to avoid this?
Contributor guide
Assessment
This issue has not been assessed yet.