I actually did all the Microsoft Tutorials for ML.NET and want to build my own models now. I want to convert string[][] data
to an IDataView-Object
, as I want to use it in an ML.NET-Model for binary classification.
So far I have always used data from external text or CSV files for the training. Now I want to use data stored in string[][] data
. In data[0][]
are the text values and in data[1][]
are the boolean
values.
I fail to convert the existing nested array into an IDataView object
. I have already tried to use the following code:
public class BinaryData
{
public string Text { get; set; }
public bool Label { get; set; }
}
// The data is collected from an Excel-Table with some functions and saved in this nested array:
string[][] data = form.GetDataSelection().GetDataContainer().textCols;
BinaryData[] inMemoryCollection = new BinaryData[data[0].Length];
for (int i = 0; i < data[0].Length-1; i++)
{
inMemoryCollection[i] = new BinaryData
{
Text = data[0][i],
Label = Convert.ToBoolean(Convert.ToInt64(data[1][i]))
};
}
IDataView dataView = mlContext.Data.LoadFromEnumerable<BinaryData>(inMemoryCollection);
My implementation is based on the tutorial from Microsoft.
It works until I want to use the Fit()-Method
. I get the following error-message:
System.InvalidOperationException: 'Splitter/consolidator worker encountered exception while consuming source data'
I hope somebody can help me out here. Many thanks in advance!