Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created May 17, 2018 00:23
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 elbruno/247220ec155c8b152637beef8d5872c9 to your computer and use it in GitHub Desktop.
Save elbruno/247220ec155c8b152637beef8d5872c9 to your computer and use it in GitHub Desktop.
MLNetSaveModel.cs
class Program
{
static void Main(string[] args)
{
var agesRangesCsv = "AgeRangeData.csv";
var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader<AgeRangeData>(agesRangesCsv, separator: ","));
pipeline.Add(new Dictionarizer("Label"));
pipeline.Add(new ColumnConcatenator("Features", "AgeStart", "AgeEnd"));
pipeline.Add(new StochasticDualCoordinateAscentClassifier());
pipeline.Add(new PredictedLabelColumnOriginalValueConverter {PredictedLabelColumn = "PredictedLabel"});
var model = pipeline.Train<AgeRangeData, AgeRangePrediction>();
var modelFilePath = "AgeRangeDataModel.zip";
model.WriteAsync(modelFilePath);
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment