Beispiel #1
0
        private int GetNearestCluster(GenericVector v)
        {
            var cluster = Centroids
                          .OrderBy(Cluster => GenericVector.Distance(Cluster.Value, v))
                          .Select(pair => pair.Key)
                          .FirstOrDefault();

            return(cluster);
        }
Beispiel #2
0
 public double SquaredErrors()
 {
     return(DataSet
            .Select(x => Math.Pow(GenericVector.Distance(x, Centroids[x.Cluster]), 2))
            .Sum());
 }