Skip to content

Instantly share code, notes, and snippets.

@mdfarragher
Created April 20, 2019 13:11
Show Gist options
  • Select an option

  • Save mdfarragher/5f1451074035e2a3dbbe61f0034ca945 to your computer and use it in GitHub Desktop.

Select an option

Save mdfarragher/5f1451074035e2a3dbbe61f0034ca945 to your computer and use it in GitHub Desktop.
This code is part of a Medium article.
/// <summary>
/// The main program class.
/// </summary>
class Program
{
// filename for dataset
private static string dataPath = Path.Combine(Environment.CurrentDirectory, "amazon0302.txt");
/// <summary>
/// The main entry point of the program.
/// </summary>
/// <param name="args">The command line arguments.</param>
static void Main(string[] args)
{
// create a machine learning context
var context = new MLContext();
// load the dataset in memory
Console.WriteLine("Loading data...");
var data = context.Data.LoadFromTextFile<ProductInfo>(
dataPath,
hasHeader: true,
separatorChar: '\t');
// split the data into 80% training and 20% testing partitions
var partitions = context.BinaryClassification.TrainTestSplit(data, testFraction: 0.2);
// the rest of the code goes here...
}
}
@AbhiAgarwal192
Copy link

Hi @mdfarragher, i have forked the file and updated it. Can you have a look at it.
https://gist.github.com/AbhiAgarwal192/b56215361a2b840485873ebedb6f8592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment