public void should_predict_nearest_label(List <DataPoint> dataPoints, List <int> pixels) { classifier.Train(dataPoints); distance.Between(dataPoints[0].Pixels, pixels).Returns(3); distance.Between(dataPoints[1].Pixels, pixels).Returns(1); distance.Between(dataPoints[2].Pixels, pixels).Returns(8); var result = classifier.Predict(pixels); result.Should().Be(dataPoints[1].Label); }
public IEnumerable <Result> Predict(Record sampleToValidateRecord, Record[] sampleRecords) { //throw new NotImplementedException(); var result = sampleRecords.Select(X => distance.Between(sampleToValidateRecord, X)); return(result); }
public string Predict(List <int> pixels) { return (trainingSet.Select(point => new { point.Label, Distance = distance.Between(point.Pixels, pixels) }) .OrderBy(arg => arg.Distance) .First() .Label); }
public Observation GetObservation(int[] pixels) { Observation currentBest = null; var shortest = double.MaxValue; foreach (var obs in _data) { var dist = _distance.Between(obs.Pixels, pixels); if (!(dist < shortest)) { continue; } shortest = dist; currentBest = obs; } return(currentBest); }
public string Predict(int[] pixels) { Observation currentBest = null; var shortest = double.MaxValue; foreach (var objs in _data) { var dist = _distance.Between(objs.Pixels, pixels); if (dist < shortest) { shortest = dist; currentBest = objs; } } return(currentBest.Label); }
public string Predict(int[] Pixels) { Observation currentBest = null; var shortest = Double.MaxValue; foreach (Observation observation in data) { var dis = distance.Between(observation.Pixels, Pixels); if (dis < shortest) { shortest = dis; currentBest = observation; } } return(currentBest.Label); }