Beispiel #1
0
        private Algorithms.GravitationalClustering RunGCAlgorithm(ref Tuple <double[], int>[] data, Algorithms.GravitationalClustering clustering, bool sim, int rand = 4)
        {
            RandomizeArray(ref data, rand);

            int take = data.Length / 2;

            foreach (var item in data.Take(take))
            {
                clustering.OnlineTrainSingular(item.Item1, item.Item2);
            }
            Debug.WriteLine("Number of Clusters " + clustering.EnumeratePlanets().Count());
            var d = data.Skip(take).Select(xx =>
            {
                int outP = 0;
                if (sim)
                {
                    outP = clustering.PredictSimulation(xx.Item1);
                }
                else
                {
                    outP = clustering.PredictProbabilistic(xx.Item1);
                }

                Debug.WriteLine("Predicted Class " + outP);
                if (outP == xx.Item2)
                {
                    return(1);
                }
                return(0);
            }).Sum();

#if DEBUG
            {
                Debug.WriteLine("Percent Accuracy " + ((double)d / ((double)data.Length - take)).ToString());
            }
#else
            {
                MessageBox.Show(((double)d / ((double)data.Length - take)).ToString());
            }
#endif
            return(clustering);
        }
Beispiel #2
0
 public void DrawClusters(Algorithms.GravitationalClustering clust)
 {
     for (int i = 0; i < 4; i++)
     {
         for (int x = i; x < 4; x++)
         {
             if (i != x)
             {
                 Graphics g = this.pictureBox1.CreateGraphics();
                 foreach (var item in clust.EnumeratePlanets())
                 {
                     this.DrawCircle(g, Pens.Red, new Point(
                                         (int)(item.Position[i] * this.ScaleCluster + this.ShiftCluster),
                                         (int)(item.Position[x] * this.ScaleCluster + 300)),
                                     (int)((item.Radius * ScaleRadius) * this.ScaleCluster * this.ScaleCluster));
                 }
                 this.ShiftCluster += 100;
             }
         }
     }
 }
Beispiel #3
0
        private Algorithms.GravitationalClustering RunProtoGCAlgoritym(ref Tuple <double[], int>[] data, Algorithms.GravitationalClustering clustering, bool sim)
        {
            var newData = this.GetProto(data);

            foreach (var item in newData)
            {
                clustering.OnlineTrainSingular(item.Item1, item.Item2);
            }
            Debug.WriteLine("Number of Clusters " + clustering.EnumeratePlanets().Count());
            var d = data.Select(xx =>
            {
                int outP = 0;
                if (sim)
                {
                    outP = clustering.PredictSimulation(xx.Item1);
                }
                else
                {
                    outP = clustering.PredictProbabilistic(xx.Item1);
                }

                Debug.WriteLine("Predicted Class " + outP);
                if (outP == xx.Item2)
                {
                    return(1);
                }
                return(0);
            }).Sum();

#if DEBUG
            {
                Debug.WriteLine("Percent Accuracy " + ((double)d / ((double)data.Length)).ToString());
            }
#else
            {
                MessageBox.Show(((double)d / ((double)data.Length)).ToString());
            }
#endif
            return(clustering);
        }