Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public sealed class ModelBuilder
private readonly string _trainingDataLocation;
private readonly ILearningPipelineItem _algorythm;
public ModelBuilder(string trainingDataLocation, ILearningPipelineItem algorythm)
_trainingDataLocation = trainingDataLocation;
_algorythm = algorythm;
/// <summary>
/// Using training data location that is passed trough constructor this method is building
/// and training machine learning model.
/// </summary>
/// <returns>Trained machine learning model.</returns>
public PredictionModel<BikeSharingDemandSample, BikeSharingDemandPrediction> BuildAndTrain()
var pipeline = new LearningPipeline();
pipeline.Add(new TextLoader(_trainingDataLocation).CreateFrom<BikeSharingDemandSample>(useHeader: true, separator: ','));
pipeline.Add(new ColumnCopier(("Count", "Label")));
pipeline.Add(new ColumnConcatenator("Features",
return pipeline.Train<BikeSharingDemandSample, BikeSharingDemandPrediction>();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment