Esempio n. 1
0
        public static void Init()
        {
            // init variables
            CsvReader.GetData();

            // set initial K -> K = 4 as centroids
            int k = numberOfCentroids;

            for (int i = 0; i < numberOfIterations; i++)
            {
                if (i == 0)
                {
                    //place K Randomly at first time.
                    centroids = Centroid.Initialize(k);
                }

                //eucl distance from centroid to offers / items
                Centroid.CalcCentroidDistance();

                //add data to cluster dictionary
                if (i > 0)
                {
                    Centroid.ClearPointList();
                }
                Centroid.AssignToCluster();

                //vergelijk oude sse met nieuw Sse
                Centroid.UpdateSSE();

                if (i > 0)
                {
                    //relocate centroids
                    centroids = Centroid.CalculateCentroidPosition();
                }
            }

            Silhouette.Init();
            foreach (var cluster in Centroid.sseCentroids)
            {
                var customers = cluster.Value;
                foreach (var customer in customers)
                {
                    Silhouette.CalculateSilhouette(customer.CustomerId);
                }
            }

            PrintResults();
            ExportExcel.Init();
            ExportExcel.CreateClusterWorkSheet();
            ExportExcel.CreateTopDealsWorkSheet();
            ExportExcel.CreateSilhouetteWorkSheet();
            ExportExcel.Export();
            Console.ReadLine();
        }