Beispiel #1
0
        internal static IMathPoint MeanPoint(IMathPoint p, IMathPoint c)
        {
            DataMiningMath.MetricEquals(p, c);

            IMathPoint meanPoint = c.Clone() as IMathPoint;

            for (Int32 i = 0; i < c.CoordinatesCount; i++)
            {
                meanPoint[i] = 0.5 * (p[i] + c[i]);
            }
            return(meanPoint);
        }
        internal static List <IMathPoint> GetRandomClusterCenters(IMathPoint minPoint, IMathPoint maxPoint, ClusteringOptions options)
        {
            Random            rnd = new Random();
            List <IMathPoint> startClusterPoints = new List <IMathPoint>(options.ClusterCount);

            // обход центров кластеризации:
            for (Int32 i = 0; i < options.ClusterCount; i++)
            {
                startClusterPoints.Add((IMathPoint)minPoint.Clone());

                // обход координат центра кластеризации:
                for (Int32 c = 0; c < startClusterPoints[i].CoordinatesCount; c++)
                {
                    startClusterPoints[i][c] = rnd.NextDouble() * (maxPoint[c] - minPoint[c]) + minPoint[c];
                }
                startClusterPoints[i].Class   = string.Format("class {0}", i + 1);
                startClusterPoints[i].Cluster = string.Format("cluster {0}", i + 1);
            }
            return(startClusterPoints);
        }