public static IMLDataSet LoadCSVToDataSet(FileInfo fileInfo, int inputCount, int outputCount, bool randomize = true, bool headers = true) { BasicMLDataSet result = new BasicMLDataSet(); CultureInfo CSVformat = new CultureInfo("en"); using (TextFieldParser parser = new TextFieldParser(fileInfo.FullName)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); if (headers) parser.ReadFields(); while (!parser.EndOfData) { //Processing row string[] fields = parser.ReadFields(); var input = new BasicMLData(inputCount); for (int i = 0; i < inputCount; i++) input[i] = double.Parse(fields[i], CSVformat); var ideal = new BasicMLData(outputCount); for (int i = 0; i < outputCount; i++) ideal[i] = double.Parse(fields[i + inputCount], CSVformat); result.Add(input, ideal); } } var rand = new Random(DateTime.Now.Millisecond); return (randomize ? new BasicMLDataSet(result.OrderBy(r => rand.Next()).ToList()) : new BasicMLDataSet(result)); }