public static decimal Distance(Dots tuple, decimal ClusterCenterC, decimal ClusterCenterY)
        {
            // Euclidean distance between two vectors
            decimal sumSquaredDiffs = 0.0M;

            sumSquaredDiffs += Convert.ToDecimal(Math.Pow((Convert.ToDouble(tuple.X - ClusterCenterC)), 2));
            sumSquaredDiffs += Convert.ToDecimal(Math.Pow((Convert.ToDouble(tuple.Y - ClusterCenterY)), 2));

            return(Convert.ToDecimal(Math.Sqrt(Convert.ToDouble(sumSquaredDiffs))));
        }
Beispiel #2
0
        public static void SetDataValidation()
        {
            DatasetValidationMatrix = new decimal[, ] {
                { 1.9801500m, -6.7806596m },
                { -2.8219563m, 19.451004m },
                { -2.0240151m, -8.6291743m },
                { 2.1564677m, -1.1332890m },
                { 2.9184940m, 16.647087m },
                { 0.38654075m, -3.3443781m },
                { -2.9318765m, 25.607553m },
                { -1.4785414m, -19.225610m },
                { 1.3084861m, 3.0795290m },
                { -1.9936273m, -9.2362868m },
                { -2.2753880m, -2.1666518m },
                { 1.4440566m, 1.4661353m },
                { 2.8710836m, 9.0010737m },
                { 1.6974342m, -4.2491447m },
                { -0.048752736m, 0.78289671m },
                { 2.0584012m, -4.7843656m },
                { -1.8306972m, -6.3331345m },
                { -1.1228797m, -4.0905619m },
                { 0.020706990m, -3.5138303m },
                { 0.20773872m, 5.2949746m },
                { 2.9030219m, 14.337840m },
                { -2.9215214m, 18.899257m },
                { 0.70547812m, 6.2670923m },
                { -2.7051131m, 21.943682m },
                { -0.67270005m, -3.9560745m },
                { -1.1797066m, -13.410109m },
                { -0.69859497m, -5.3756579m },
                { 1.8026191m, -3.1878678m },
                { 1.7048566m, 8.7244855m },
                { -1.5576905m, -12.160641m },
                { -2.7152747m, 20.711627m },
                { -1.0395723m, -11.141173m },
                { -2.1720095m, -0.18288778m },
                { -0.90355720m, -11.987174m },
                { -0.38657873m, -9.5474606m },
                { -0.30872735m, -1.5581771m },
                { 1.4224345m, -11.123535m },
                { -0.70805045m, -7.5211539m },
                { 0.56768730m, -4.3412780m },
                { -1.1239144m, -0.11073149m },
                { -2.1903506m, 5.2470613m },
                { -2.0212017m, 0.58115095m },
                { -2.9998796m, 30.430512m },
                { -2.1055614m, 0.53958871m },
                { 1.0257015m, -4.5455824m },
                { -1.3861645m, -4.7831224m },
                { 0.65146764m, 3.1380058m },
                { -0.38033538m, -10.744844m },
                { -2.0281952m, 0.53544639m },
                { -0.30265895m, -6.9052790m },
                { 1.4454759m, 1.5849510m },
                { 2.1786579m, 4.8820055m },
                { -1.7085864m, -5.5829683m },
                { 2.0291894m, -4.6698264m },
                { 0.11870335m, 12.267529m },
                { -2.3441984m, -5.2155277m },
                { -1.5431555m, -15.379571m },
                { -2.0486046m, 7.9104820m },
                { 2.8054939m, 11.691854m },
                { 2.8981378m, 14.659047m },
                { -2.3430606m, 8.5409437m },
                { 0.84513887m, -1.8453196m },
                { 2.8009688m, 7.7448307m },
                { -0.63567421m, -8.2648927m },
                { 2.6501168m, -3.9104836m },
                { -2.7342517m, 21.670256m },
                { -0.12824770m, -1.0840106m },
                { -2.5231842m, 12.902442m },
                { -1.0985050m, -15.167126m },
                { 1.8124092m, 0.58770455m },
                { 2.6235477m, 5.4078014m },
                { -2.9804723m, 24.530535m },
                { -1.9626816m, -7.1457525m },
                { 1.6345047m, -6.2579855m },
                { -1.9387665m, -3.1620106m },
                { 0.17727955m, 0.90797673m },
                { -2.1581151m, 5.2672431m },
                { -1.9964186m, -6.4154674m },
                { -2.3773904m, 5.7287844m },
                { -2.7420602m, 21.712374m },
                { 0.16823816m, -3.1466554m },
                { 1.0823106m, -6.0673208m },
                { -1.3220437m, -11.678548m },
                { 2.9405627m, 13.809188m },
                { 0.40319194m, 9.7245355m },
                { -2.8656152m, 28.102968m },
                { 2.6145754m, 8.8064694m },
                { -2.2014330m, -4.0375464m },
                { 2.2299934m, -9.2295978m },
                { -1.0624892m, -15.805793m },
                { 1.0799518m, -2.6921023m },
                { -0.29297608m, -0.49559519m },
                { 1.4187360m, 2.9859520m },
                { -2.1963350m, 5.4103842m },
                { -2.0890854m, -4.9285353m },
                { 1.8271138m, 1.9453618m },
                { -0.13239170m, -1.5767970m },
                { 0.63460063m, 6.0896994m },
                { 1.8052850m, -2.3478010m },
                { -2.7981345m, 21.458954m }
            };

            DatasetValidation = new List <Dots>();

            for (int i = 0; i < 50; i++)
            {
                Dots x = new Dots()
                {
                    X = DatasetValidationMatrix[i, 0],
                    Y = DatasetValidationMatrix[i, 1]
                };
                x.DistanceToCentersByX  = new decimal[10];
                x.DistanceToCentersByXY = new decimal[10];
                x.BelongingCluster      = new decimal[10];

                Array.Copy(Distance, x.DistanceToCentersByX, 10);
                Array.Copy(Distance, x.DistanceToCentersByXY, 10);
                Array.Copy(Distance, x.BelongingCluster, 10);


                DatasetValidation.Add(x);
            }
        }
Beispiel #3
0
        public static void SetDataTrain()
        {
            DatasetTrainMatrix = new decimal[, ] {
                { 0.88780483m, 7.0887174m },
                { -1.1968985m, -6.6488336m },
                { -0.68052170m, 1.3097657m },
                { 1.0287499m, -5.4677192m },
                { -2.3360415m, 8.8795970m },
                { 2.0833673m, 0.57597640m },
                { 2.7345112m, 6.9868772m },
                { -1.3309695m, -14.275200m },
                { -1.3367205m, -25.496883m },
                { 1.2805311m, 2.4558209m },
                { 1.4816721m, -0.015850570m },
                { -1.3775442m, -9.1098026m },
                { -1.9804606m, -11.821141m },
                { 0.26416734m, 1.4949945m },
                { 2.5025817m, 2.8328359m },
                { -1.3069600m, -8.3596439m },
                { -2.7493471m, 19.788724m },
                { 0.54604472m, 1.8262313m },
                { -0.30459961m, -1.6278779m },
                { -0.0074886221m, 9.3569256m },
                { -0.60473135m, -6.3361141m },
                { -1.5286133m, -11.438209m },
                { -0.56955603m, 2.2677300m },
                { -1.6502073m, -6.2717687m },
                { -2.5544316m, 16.664973m },
                { 0.65873594m, 5.4564557m },
                { -1.2795672m, -16.601525m },
                { 0.13147199m, -0.19194773m },
                { 2.6959424m, 7.3634771m },
                { -1.6362543m, -7.9847972m },
                { 2.2564104m, 0.84136470m },
                { -2.0630098m, 7.3215420m },
                { 0.21378808m, -3.9400823m },
                { -2.3073679m, 1.5507389m },
                { 2.1178858m, 5.2635498m },
                { 1.8710147m, 3.6535214m },
                { 2.1703751m, -7.4149324m },
                { 0.19266638m, 4.5657470m },
                { 2.7151430m, 9.7424533m },
                { 2.7084072m, 10.563553m },
                { 0.71303339m, -5.0929726m },
                { 0.96921643m, 1.5522667m },
                { 2.1075150m, -3.5609573m },
                { -1.9325934m, 2.5843997m },
                { -1.0323079m, -9.0392924m },
                { 1.1777262m, -5.0195118m },
                { -0.23567409m, 5.7098848m },
                { 2.9339167m, 10.216238m },
                { -2.4524210m, 10.006393m },
                { -0.88186763m, -14.970309m }
            };
            DatasetTrain = new List <Dots>();

            for (int i = 0; i < 50; i++)
            {
                Dots x = new Dots()
                {
                    X = DatasetTrainMatrix[i, 0],
                    Y = DatasetTrainMatrix[i, 1]
                };
                x.DistanceToCentersByX  = new decimal[10];
                x.DistanceToCentersByXY = new decimal[10];
                x.BelongingCluster      = new decimal[10];


                Array.Copy(Distance, x.DistanceToCentersByX, 10);
                Array.Copy(Distance, x.DistanceToCentersByXY, 10);
                Array.Copy(Distance, x.BelongingCluster, 10);

                DatasetTrain.Add(x);
            }
        }