public async Task GetPrediction(float[] image) { var digit = MinstDigit.FromList(image, false); var prediction = ml.Predict(digit); prediction.Label = prediction.Score.Select((value, index) => new { Value = value, Index = index }).Aggregate((a, b) => (a.Value > b.Value) ? a : b).Index; await Clients.Caller.SendAsync("receivePrediction", image, prediction); await Clients.All.SendAsync("receiveBackground", image, prediction); }
public MLModel() { var pipeline = new LearningPipeline(); string dataPath = "./train.csv"; pipeline.Add(new TextLoader(dataPath).CreateFrom <MinstDigit>(separator: ',', useHeader: true)); pipeline.Add(new ColumnConcatenator("Features", MinstDigit.GetColumnNames())); pipeline.Add(new StochasticDualCoordinateAscentClassifier()); _model = pipeline.Train <MinstDigit, MinstPrediction>(); this.Evaluate(); //this.Export(); }
public MinstPrediction Predict(MinstDigit digit) { return(_model.Predict(digit)); }