Example #1
0
        /// <summary>
        ///  Afstanden bereken binnen een cluster voor Cohesion
        /// </summary>
        /// <param name="customerId">KlantId X</param>
        /// <param name="centroid">Cluster Centroid X</param>
        public static void CalculateDistanceCohesion(int customerId, int centroid)
        {
            if (!DistancesCohesion.ContainsKey(centroid))
            {
                DistancesCohesion.Add(centroid, new List <Tuple <int, int, double> >());
            }
            Euclidean euclidean       = new Euclidean();
            var       cluster         = Centroid.sseCentroids[centroid];
            var       filterCustomers = cluster.Where(customer => customer.CustomerId != customerId);

            foreach (var customer in filterCustomers)
            {
                if (!HasDuplicate(customerId, customer.CustomerId, centroid))
                {
                    int[] pointX = Centroid.sseCentroids[centroid].Find(c => c.CustomerId == customerId).Offer.ToArray();
                    DistancesCohesion[centroid].Add(new Tuple <int, int, double>(customerId, customer.CustomerId, euclidean.ComputeDistance(pointX, customer.Offer.ToArray())));
                }
            }
        }
Example #2
0
        /// <summary>
        ///  Berekent afstand voor Seperation
        /// </summary>
        /// <param name="customerId">KlantId X</param>
        public static void CalculateDistanceSeperation(int customerId)
        {
            if (!DistancesSeperation.ContainsKey(customerId))
            {
                DistancesSeperation.Add(customerId, new List <Tuple <int, int, double> >());
            }
            Euclidean euclidean        = new Euclidean();
            var       customerCentroid = Centroid.GetSSECentroidByCustomerId(customerId);

            foreach (var cluster in Centroid.sseCentroids)
            {
                if (cluster.Key != customerCentroid)
                {
                    foreach (var customer in cluster.Value)
                    {
                        if (!HasDuplicate2(customerId, customer.CustomerId))
                        {
                            int[] pointX = Centroid.sseCentroids[customerCentroid].Find(c => c.CustomerId == customerId).Offer.ToArray();
                            DistancesSeperation[customerId].Add(new Tuple <int, int, double>(cluster.Key, customer.CustomerId, euclidean.ComputeDistance(pointX, customer.Offer.ToArray())));
                        }
                    }
                }
            }
        }