Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /// <summary>
  2. /// Using training data location that is passed trough constructor this method is building
  3. /// and training machine learning model.
  4. /// </summary>
  5. /// <returns>Trained machine learning model.</returns>
  6. public PredictionModel<IrisFlower, IrisPredict> BuildAndTrain()
  7. {
  8. var pipeline = new LearningPipeline();
  9. pipeline.Add(new TextLoader(_trainingDataLocation).CreateFrom<IrisFlower>(useHeader: true, separator: ','));
  10. pipeline.Add(new Dictionarizer("Label"));
  11. pipeline.Add(new ColumnConcatenator("Features", "SepalLength", "SepalWidth", "PetalLength", "PetalWidth"));
  12. pipeline.Add(new StochasticDualCoordinateAscentClassifier());
  13. pipeline.Add(new PredictedLabelColumnOriginalValueConverter() { PredictedLabelColumn = "PredictedLabel" });
  14.  
  15. return pipeline.Train<IrisFlower, IrisPredict>();
  16. }
Add Comment
Please, Sign In to add comment