private int GetNearestCluster(GenericVector v) { var cluster = Centroids .OrderBy(Cluster => GenericVector.Distance(Cluster.Value, v)) .Select(pair => pair.Key) .FirstOrDefault(); return(cluster); }
public double SquaredErrors() { return(DataSet .Select(x => Math.Pow(GenericVector.Distance(x, Centroids[x.Cluster]), 2)) .Sum()); }