Exemple #1
0
        static void Main(string[] args)
        {
            const int size = 100000;
            int       dim  = 2;
            var       data = new List <Point>(size);
            var       rand = new Random();

            int x, y;

            for (int i = 0; i < size; ++i)
            {
                x = rand.Next(0, 255);
                y = rand.Next(0, 255);
                data.Add(new Point(dim, x, y));
            }
            int k = 64;

            var model = new Kmeans(k, dim);

            var timer = new Stopwatch();

            timer.Start();
            var labels = model.Fit(data);

            timer.Stop();

            TimeSpan timeTaken = timer.Elapsed;

            Console.WriteLine($"elapsed time:{ timeTaken.ToString(@"m\:ss\.fff")}");
        }
Exemple #2
0
        private void run_btn_Click(object sender, EventArgs e)
        {
            var num_clusters = Int32.Parse(num_cluster_txtbox.Text);

            if (kmeans_cb.Checked)
            {
                var kmeans = new Kmeans(data, num_clusters);
                var result = kmeans.Get_clusters();
                visualise(data.Points, result);
                var path_out = Path.Combine(Path.GetDirectoryName(path_textbox.Text), "kmeans.txt");
                writer.write_data(data, result.Clusters, path_out);
            }
        }
Exemple #3
0
        private void run_btn_Click(object sender, EventArgs e)
        {
            if (data == null)
            {
                MessageBox.Show("Please select datasets!");
                return;
            }

            if (kmeans_cb.Checked)
            {
                var num_clusters = Int32.Parse(num_cluster_txtbox.Text);
                var kmeans       = new Kmeans(data, num_clusters);
                var result       = kmeans.Get_clusters();
                visualise(data.Points, result);
                var path_out = Path.Combine(Path.GetDirectoryName(path_textbox.Text), "kmeans.txt");
                writer.write_data(data, result.Clusters, path_out);
            }
            if (DBSan_cb.Checked)
            {
                if (EpsValue_textBox.Text == "")
                {
                    MessageBox.Show("Please input eps and minpts!");
                    return;
                }
                if (enterMin_textBox.Text == "")
                {
                    MessageBox.Show("Please input eps and minpts!");
                    return;
                }
                var f_Eps    = double.Parse(EpsValue_textBox.Text);
                var f_minPts = Int32.Parse(enterMin_textBox.Text);
                var dbscan   = new DBSCAN(data, f_Eps, f_minPts);
                var result   = dbscan.Get_clusters();
                //visualise(data.Points, result);
                // var path_out = Path.Combine(Path.GetDirectoryName(path_textbox.Text), "kmeans.txt");
                // writer.write_data(data, result.Clusters, path_out);
            }
        }