Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created April 30, 2019 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndyButland/9ac355c6c6981855db91dd181af10bec to your computer and use it in GitHub Desktop.
Save AndyButland/9ac355c6c6981855db91dd181af10bec to your computer and use it in GitHub Desktop.
public static void Main(string[] args)
{
var context = new MLContext();
var data = GetTrainAndTestData(context, InputDataPath);
...
}
private static TrainCatalogBase.TrainTestData GetTrainAndTestData(MLContext context, string dataPath)
{
// Load data from the CSV file.
var dataView = context.Data.LoadFromTextFile<CountryData>(dataPath, hasHeader: true, separatorChar: ',');
// Split the data randomly, in 90:10 ratio, for training and evaluation data respectively.
return context.MulticlassClassification.TrainTestSplit(dataView, testFraction: 0.1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment