Ejemplo n.º 1
0
 private string Predict(Iris member, int k) =>
 this.trainingSet.OrderBy(member.GetEucledeanDistance)
 .Take(k)
 .GroupBy(i => i.Species)
 .OrderByDescending(g => g.Count())
 .ThenBy(g => g.Sum(i => member.GetEucledeanDistance(i)))
 .First()
 .Key;
Ejemplo n.º 2
0
 public double GetEucledeanDistance(Iris other) =>
 Math.Sqrt(Math.Pow(this.SepalLengthCm - other.SepalLengthCm, 2) +
           Math.Pow(this.SepalWidthCm - other.SepalWidthCm, 2) +
           Math.Pow(this.PetalLengthCm - other.PetalLengthCm, 2) +
           Math.Pow(this.PetalWidthCm - other.PetalWidthCm, 2));