Ejemplo n.º 1
0
        private void CallApriori(double support)
        {
            int result = 0;

            Apriori algorithm = new Apriori(support);

            algorithm.MileStoneEvent += algorithm_MileStoneEvent;
            algorithm.InputDataFile   = textDataFile.Text;
            algorithm.Process();
        }
Ejemplo n.º 2
0
        }//DMForm

        //Methods *************************************************************
        //Events **************************************************************
        private void btnExecute_Click(object sender, EventArgs e)
        {
            if (cmbAlgorithm.SelectedItem == null)
            {
                MessageBox.Show("Please select an algorithm.");
                return;
            }//if no algorithm

            string algorithm = cmbAlgorithm.SelectedItem.ToString();

            if (algorithm.Equals("Apriori"))
            {
                rtbResults.Text = "";
                List <ItemSetDto> results = new List <ItemSetDto>();
                DateTime          timer   = DateTime.Now;
                if (cmbSource.SelectedItem == null)
                {
                    MessageBox.Show("Please select a data source.");
                    return;
                }//if

                if (txtMinSupport.Text.Equals(""))
                {
                    MessageBox.Show("Please enter a Minimum Support");
                    return;
                }//if

                double minSupport = Convert.ToDouble(txtMinSupport.Text);
                string datasource = cmbSource.SelectedItem.ToString();

                DataSourceBLL dsBLL = new DataSourceBLL();
                Apriori       ap    = new Apriori();

                List <TransactionDto> transactions = dsBLL.process(datasource);

                if (transactions == null)
                {
                    return;
                }

                results = ap.Process(transactions, null, minSupport);

                StringBuilder sb = new StringBuilder();
                foreach (ItemSetDto isd in results)
                {
                    sb.AppendLine(isd.toString());
                }

                rtbResults.AppendText(sb.ToString() + "\nTime to Complete: " + (DateTime.Now - timer).ToString());
            }//if "Apriori"
            else if (algorithm.Equals("FPGrowth"))
            {
                if (txtMinSupport.Text.Equals(""))
                {
                    MessageBox.Show("Please enter a Minimum Support");
                    return;
                }//if
                double                minSupport = Convert.ToDouble(txtMinSupport.Text);
                string                datasource = cmbSource.SelectedItem.ToString();
                DataSourceBLL         dsBLL      = new DataSourceBLL();
                List <TransactionDto> dtos       = dsBLL.process(datasource);

                if (dtos == null)
                {
                    return;
                }

                rtbResults.Text = "";
                DateTime timer            = DateTime.Now;
                FPGrowth fpg              = new FPGrowth(dtos, minSupport);
                List <FrequentPattern> fp = fpg.mine();
                StringBuilder          sb = new StringBuilder();
                foreach (FrequentPattern f in fp)
                {
                    sb.AppendLine(f.ToString());
                }

                rtbResults.AppendText(sb.ToString() + "\nTime to Complete: " + (DateTime.Now - timer).ToString());
            }//if "FPGrowth"
            else if (algorithm.Equals("Eclat"))
            {
                rtbResults.Text = "";
                List <VerticalItemSetDto> results = new List <VerticalItemSetDto>();
                DateTime timer = DateTime.Now;
                if (cmbSource.SelectedItem == null)
                {
                    MessageBox.Show("Please select a data source.");
                    return;
                }//if

                if (txtMinSupport.Text.Equals(""))
                {
                    MessageBox.Show("Please enter a Minimum Support");
                    return;
                }//if

                double minSupport = Convert.ToDouble(txtMinSupport.Text);
                string datasource = cmbSource.SelectedItem.ToString();

                DataSourceBLL dsBLL = new DataSourceBLL();
                Eclat         ec    = new Eclat();

                List <TransactionDto> transactions = dsBLL.process(datasource);

                if (transactions == null)
                {
                    return;
                }

                results = ec.Process(transactions, null, minSupport);

                StringBuilder sb = new StringBuilder();
                foreach (VerticalItemSetDto isd in results)
                {
                    sb.AppendLine(isd.toString());
                }

                rtbResults.AppendText(sb.ToString() + "\nTime to Complete: " + (DateTime.Now - timer).ToString());
            } //if "Eclat"
        }     //btnExecute_Click