-
-
Save mdfarragher/a41971907f1ddb08418028096d706a92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// The main program class. | |
/// </summary> | |
public class Program | |
{ | |
// filenames for data set | |
private static string dataPath = Path.Combine(Environment.CurrentDirectory, "spam.tsv"); | |
/// <summary> | |
/// The main program entry point. | |
/// </summary> | |
/// <param name="args">The command line parameters.</param> | |
static void Main(string[] args) | |
{ | |
// set up a machine learning context | |
var context = new MLContext(); | |
// load the spam dataset in memory | |
Console.WriteLine("Loading data..."); | |
var data = context.Data.LoadFromTextFile<SpamData>( | |
path: dataPath, | |
hasHeader: true, | |
separatorChar: '\t'); | |
// use 80% for training and 20% for testing | |
var partitions = context.Data.TrainTestSplit(data, testFraction: 0.3); | |
// set up a pipeline to featurize the text | |
Console.WriteLine("Featurizing text..."); | |
var pipeline = context.Transforms.Text.FeaturizeText( | |
outputColumnName: "Features", | |
inputColumnName: nameof(SpamData.Message)); | |
// the rest of the code goes here... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment