Exemplo n.º 1
0
 public ClusterPoint(ClusterPoint p, int clusterNumber)
 {
     this.X             = p.X;
     this.Y             = p.Y;
     this.XT            = p.XT;
     this.YT            = p.YT;
     this.ClusterNumber = clusterNumber;
 }
Exemplo n.º 2
0
        private void InitializeCentroids()
        {
            Random rnd = new Random();

            clusterData.Centroids = new List <ClusterPoint>();

            for (int i = 0; i < this.K; i++)
            {
                ClusterPoint p = clusterData.Points[rnd.Next(clusterData.Points.Count)];
                clusterData.Centroids.Add(new ClusterPoint(p, i));
            }
        }
Exemplo n.º 3
0
 public void Add(ClusterPoint point)
 {
     Points.Add(point);
 }
Exemplo n.º 4
0
 public static double Chebyshev(ClusterPoint p1, ClusterPoint p2) => Max(Abs(p1.XT - p2.XT), Abs(p1.YT - p2.YT));
Exemplo n.º 5
0
 public static double Manhattan(ClusterPoint p1, ClusterPoint p2) => Abs(p1.XT - p2.XT) + Abs(p1.YT - p2.YT);
Exemplo n.º 6
0
 public static double Euclidean(ClusterPoint p1, ClusterPoint p2) => Sqrt(SquaredEuclidean(p1, p2));
Exemplo n.º 7
0
 public static double SquaredEuclidean(ClusterPoint p1, ClusterPoint p2) =>
 (p1.XT - p2.XT) * (p1.XT - p2.XT) + (p1.YT - p2.YT) * (p1.YT - p2.YT);