Esempio n. 1
0
        public static double CalcSSE(List <Iris> listI, Centroid irisSetosa, Centroid irisVersicolor, Centroid irisVirginica)
        {
            double minimumSetosa     = CentroidMover.CountDist(listI[0], irisSetosa);
            double minimumVersicolor = CentroidMover.CountDist(listI[0], irisVersicolor);
            double minimumVirginica  = CentroidMover.CountDist(listI[0], irisVirginica);

            foreach (Iris i in listI)
            {
                switch (i.Centroid.Name)
                {
                case ("Setosa"):
                    double t = CentroidMover.CountDist(i, irisSetosa);
                    if (minimumSetosa > t)
                    {
                        minimumSetosa = t;
                    }
                    continue;

                case ("Versicolor"):
                    double tV = CentroidMover.CountDist(i, irisVersicolor);
                    if (minimumVersicolor > tV)
                    {
                        minimumVersicolor = tV;
                    }
                    continue;

                case ("Virginica"):
                    double tVi = CentroidMover.CountDist(i, irisVirginica);
                    if (minimumVirginica > tVi)
                    {
                        minimumVirginica = tVi;
                    }
                    continue;
                }
            }
            double total = Math.Pow(minimumSetosa, 2) + Math.Pow(minimumVersicolor, 2) + Math.Pow(minimumVirginica, 2);

            return(total);
        }
Esempio n. 2
0
        public static double CalcSSE(List <Iris> listI, Centroid irisSetosa, Centroid irisVersicolor, Centroid irisVirginica)
        {
            double minimumSetosa     = CentroidMover.CountDist(listI[0], irisSetosa);
            double minimumVersicolor = CentroidMover.CountDist(listI[0], irisVersicolor);
            double minimumVirginica  = CentroidMover.CountDist(listI[0], irisVirginica);

            foreach (Iris i in listI)
            {
                if (irisSetosa.Name == i.Centroid.Name)
                {
                    double t = CentroidMover.CountDist(i, irisSetosa);
                    if (minimumSetosa > t)
                    {
                        minimumSetosa = t;
                    }
                }
                else if (irisVersicolor.Name == i.Centroid.Name)
                {
                    double tV = CentroidMover.CountDist(i, irisVersicolor);
                    if (minimumVersicolor > tV)
                    {
                        minimumVersicolor = tV;
                    }
                }
                else if (irisVirginica.Name == i.Centroid.Name)
                {
                    double tVi = CentroidMover.CountDist(i, irisVirginica);
                    if (minimumVirginica > tVi)
                    {
                        minimumVirginica = tVi;
                    }
                }
            }
            double total = Math.Pow(minimumSetosa, 2) + Math.Pow(minimumVersicolor, 2) + Math.Pow(minimumVirginica, 2);

            return(total);
        }