private void btnTraining_Click_1(object sender, EventArgs e) { if (cmbSource.SelectedItem == null) { MessageBox.Show("Please select a data source."); return; }//if string datasource = cmbSource.SelectedItem.ToString(); DataSourceBLL dsBLL = new DataSourceBLL(); trainingDtos = dsBLL.process(datasource); TransactionDto t1 = trainingDtos[0]; foreach (string i in t1.items) { cmbColumn.Items.Add(i); } cmbColumn.SelectedIndex = t1.items.Count - 1; btnTrain.Enabled = true; if (DialogResult.Yes == MessageBox.Show("Does your file have headers?", "File import", MessageBoxButtons.YesNo)) { trainingDtos.RemoveAt(0); } }
private void btnLoad_Click(object sender, EventArgs e) { //kmeansForm.randomMark = "n"; if (Kval == String.Empty) { MessageBox.Show("Please specify a K value."); return; }//end if if (this.comboBox1.SelectedItem == null) { MessageBox.Show("Please select a data source."); return; }//if string datasource = this.comboBox1.SelectedItem.ToString(); DataSourceBLL dsBLL = new DataSourceBLL(); trainingDtos = dsBLL.process(datasource); if (DialogResult.Yes == MessageBox.Show("Does your file have headers?", "File import", MessageBoxButtons.YesNo)) { trainingDtos.RemoveAt(0); } StringBuilder sb; sb = NewKmeans.kmeanst(trainingDtos); this.dataGridView1.DataSource = NewKmeans._points; this.txtData.Text = sb.ToString(); }
private void btnLoad_Click(object sender, EventArgs e) { if (this.comboBox1.SelectedItem == null) { MessageBox.Show("Please select a data source."); return; }//if string datasource = this.comboBox1.SelectedItem.ToString(); DataSourceBLL dsBLL = new DataSourceBLL(); trainingDtos = dsBLL.process(datasource); if (DialogResult.Yes == MessageBox.Show("Does your file have headers?", "File import", MessageBoxButtons.YesNo)) { trainingDtos.RemoveAt(0); } /*NewKmeans kmeans2 = new NewKmeans(); StringBuilder sb2 = kmeans2.kmeanst(trainingDtos); this.txtData.Text = sb2.ToString(); List<NewKmeans.XY> dsList = new List<NewKmeans.XY>(); dsList = kmeans2.Data(trainingDtos); String listds = String.Empty; foreach (NewKmeans.XY XY in dsList) { listds += "(" + XY.XToString + " " + XY.YToString + ") , "; }//end foreach */ //NewKmeans k = new NewKmeans(); List<NewKmeans.XY> points; points = NewKmeans.Data(trainingDtos); String listp = String.Empty; foreach(NewKmeans.XY p in points){ listp += "(" + p.XToString + ", " + p.YToString + ")"; this.textBox1.Text = listp; }//end foreach this.dataGridView1.DataSource = points; StringBuilder sb = NewKmeans.kmeanst(trainingDtos); this.txtData.Text = sb.ToString(); }
private void btnClassify_Click(object sender, EventArgs e) { if (cmbSource.SelectedItem == null) { MessageBox.Show("Please select a data source."); return; }//if string datasource = cmbSource.SelectedItem.ToString(); DataSourceBLL dsBLL = new DataSourceBLL(); List<TransactionDto> dtos = dsBLL.process(datasource); if (DialogResult.Yes == MessageBox.Show("Does your file have headers?", "File import", MessageBoxButtons.YesNo)) { dtos.RemoveAt(0); } foreach (TransactionDto dto in dtos) { string classification = dtree.decide(dto); txtResults.Text += dto.tid + ": " + classification + Environment.NewLine; } }
//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" }