Exemple #1
0
 private void voBtnKMedoid_Click(object sender, EventArgs e)
 {
     try
     {
         // define distance function
         Func <Point, Point, double> koEuclidean = (a, b) => Math.Sqrt(Math.Pow((a.X - b.X), 2) + Math.Pow((a.Y - b.Y), 2));
         this.voKM = new KMedoid <Point>(koEuclidean);
         int kiK = int.Parse(this.voTbK.Text);
         this.voKM.MCompute(kiK, this.voPList);
         Visualization.MDrawClusters(this.voPB, this.voPList, this.voKM.VoClusters, kiK,
                                     this.voKM.VdMedoids.ToList( ), 0.7);
         this.voTbResult.Text = mComputeAndShowVarianceResults(kiK);
     }
     catch (Exception koEx)
     {
         MessageBox.Show(koEx.Message);
     }
 }
Exemple #2
0
 private void btnKMedoid_Click(object sender, EventArgs e)
 {
     try
     {
         // define distance function
         Func <Point, Point, double> euclidean = (a, b) => Math.Sqrt(Math.Pow((a.X - b.X), 2) + Math.Pow((a.Y - b.Y), 2));
         km = new KMedoid <Point>(euclidean);
         int k = int.Parse(txtClusters.Text);
         compute.Start();
         km.Compute(k, PList);
         compute.Stop();
         MessageBox.Show("Time elapsed to compute (ms): " + compute.ElapsedMilliseconds);
         Visualization.DrawClusters(pic1, PList, km.Clusters, k, km._medoids, 0.7);
         txtResult.Text = ComputeAndShowVarianceResults(k);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }