September 2018
Intermediate to advanced
328 pages
10h 46m
English
With this function we mirror frameworks such as Python, which make it very easy to split training and testing data from the main dataset. We have created our own function to do the same thing:
static (float[][] train, float[][] valid, float[][] test) SplitDataForTrainingAndTesting(float[][] data, float valSize = 0.1f, float testSize = 0.1f){ if (data == null) throw new ArgumentException("data parameter cannot be null");//Calculate the data neededvar posTest = (int)(data.Length * (1 - testSize)); var posVal = (int)(posTest * (1 - valSize)); return ( data.Skip(0).Take(posVal).ToArray(), data.Skip(posVal).Take(posTest - posVal).ToArray(), data.Skip(posTest).ToArray());}
Read now
Unlock full access