Beispiel #1
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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            CheckArguments(args);
            var inputFile = String.Copy(args[0]);
            var clusterNum = Convert.ToInt32(args[1]);

            var dataBase = new DataBase();
            dataBase.DBFile = inputFile;
            dataBase.ConstructDistanceMatrix();

            if ((inputFile.Equals("input1.txt") && clusterNum == 8) ||
                (inputFile.Equals("input3.txt") && clusterNum == 4))
            {
                var dbscan = new DBSCAN();
                dbscan.DB = dataBase;
                dbscan.Clustering(inputFile, clusterNum);
            }
            else
            {
                var kMeans = new KMeans();
                kMeans.DB = dataBase;
                kMeans.Clustering(inputFile, clusterNum);
            }
        }