Example #1
0
        //method to generate a string of data for the form
        //this method used for file uploads
        public static StringBuilder kmeanst(List <TransactionDto> trainingDtos)
        {
            if (trainingDtos == null)
            {
                System.Windows.Forms.MessageBox.Show("no data");
            }
            GlobalClass.program += "1. kmeanst .. ";

            datainput = trainingDtos;
            num       = 100;

            Starttime = DateTime.Now;
            var algo = new NewKmeans();

            // run kmeans or grid
            algo.Run(ClusterType.KMeans);
            //algo.Run(ClusterType.Grid);

            StringBuilder sb =
                algo.GenerateClusterGrid();

            return(sb);


            //var timespend = DateTime.Now.Subtract(Starttime).TotalSeconds;
        }
        //public static KmeansCluster kmc = new KmeansCluster();

        //method to generate a string of data for the form
        //this method used for file uploads
        public static StringBuilder kmeanst(List<TransactionDto> trainingDtos)
        {

            if (trainingDtos == null)
                System.Windows.Forms.MessageBox.Show("no data");
            GlobalClass.program += "1. kmeanst .. ";

            datainput = trainingDtos;
            num = 100;

            Starttime = DateTime.Now;
            var algo = new NewKmeans();

            // run kmeans 
            algo.Run(ClusterType.KMeans);

            StringBuilder sb =
                algo.GenerateClusterGrid();

            return sb;


            //var timespend = DateTime.Now.Subtract(Starttime).TotalSeconds;

        }
Example #3
0
        //method to generate a string of data for the form
        //this method used to generate random data
        public static StringBuilder kmeanstoo()
        {
            GlobalClass.program += "2. kmeanstoo .. ";
            datainput            = null;
            Starttime            = DateTime.Now;
            var algo = new NewKmeans();

            // run kmeans or grid
            algo.Run(ClusterType.KMeans);
            //algo.Run(ClusterType.Grid);

            StringBuilder sb =
                algo.GenerateClusterGrid();

            return(sb);


            //var timespend = DateTime.Now.Subtract(Starttime).TotalSeconds;
        }
        //method to generate a string of data for the form
        //this method used to generate random data
        public static StringBuilder kmeanstoo(List<XY> _pointsa)
        {
            GlobalClass.program += "2. kmeanstoo .. ";
            datainput2 = _pointsa;
            Starttime = DateTime.Now;
            var algo = new NewKmeans();

            // run kmeans 
            algo.Run(ClusterType.KMeans);

            StringBuilder sb =
                algo.GenerateClusterGrid();

            return sb;


            //var timespend = DateTime.Now.Subtract(Starttime).TotalSeconds;

        }
 public Segment(NewKmeans.XY p1, NewKmeans.XY p2)
 {
     P1 = p1;
     P2 = p2;
 }
            private const double Exp = 2; // 2=euclid, 1=manhatten

            #endregion Fields

            #region Methods

            //Minkowski dist
            public static double Distance(NewKmeans.XY a, NewKmeans.XY b)
            {
                return Math.Pow(Math.Pow(Math.Abs(a.X - b.X), Exp) +
                    Math.Pow(Math.Abs(a.Y - b.Y), Exp), 1.0 / Exp);
            }
        //method to generate a string of data for the form
        //this method used to generate random data
        public static StringBuilder kmeanstoo()
        {
            GlobalClass.program += "2. kmeanstoo .. ";
            datainput = null;
            Starttime = DateTime.Now;
            var algo = new NewKmeans();

            // run kmeans or grid
            algo.Run(ClusterType.KMeans);
            //algo.Run(ClusterType.Grid);

            StringBuilder sb =
                algo.GenerateClusterGrid();

            return sb;
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            NewKmeans kmeans = new NewKmeans();
            StringBuilder sb =  NewKmeans.kmeanstoo();

            this.txtData.Text = sb.ToString();

            List<NewKmeans.XY> dsList = new List<NewKmeans.XY>();

            dsList =  NewKmeans.CreateDataSet();

            String listds = String.Empty;
            foreach(NewKmeans.XY XY in dsList){

                listds +=  "(" + XY.XToString + "  " + XY.YToString + ") , ";

            }//end foreach

            //this.txtData.Text = listds;

            this.dataGridView1.DataSource = dsList;
        }