private void AprioriAlog(IFormFile newFile) { int Support = 2; if (newFile != null && newFile.Length > 0) { using (var tr = new System.IO.StreamReader(newFile.OpenReadStream())) { while ((line = tr.ReadLine()) != null) { line.Replace("\t", "#"); lines.Add(line); } } } else { } List <BAL.ItemSet> tableitemset = GetitemList(lines.ToList()); // Fill table of items newList = tableitemset; // BAL.Apriori aprioriTid = new BAL.Apriori(tableitemset.ToList()); BAL.Apriori apriori = new BAL.Apriori(lines.ToList()); int k = 1; List <BAL.ItemSet> ItemSets = new List <BAL.ItemSet>(); bool next; do { next = false; var L = apriori.GetItemSet(k, Support, IsFirstItemList: k == 1); if (L.Count > 0) { List <AssociationRule> rules = new List <AssociationRule>(); if (k != 1) { rules = apriori.GetRules(L); } // TableUserControl tableL = new TableUserControl(L, rules); _LList.Add(new BAL.ItemSet() { Support = 0, Label = "L" + k }); TableUserControl(L, rules); next = true; k++; ItemSets.Add(L); } } while (next); }
private void DoThings() { int Support = 2; if (FileUploadControl.PostedFile != null && FileUploadControl.PostedFile.FileName != "" && FileUploadControl.PostedFile.ContentLength > 0) { using (System.IO.TextReader tr = new System.IO.StreamReader(FileUploadControl.PostedFile.InputStream)) { while ((line = tr.ReadLine()) != null) { line.Replace("\t", "#"); lines.Add(tr.ReadLine()); } ViewState["lines"] = lines; } } else { lines = (List <string>)ViewState["lines"]; } DataTable dt = TableUserControl(lines.ToList()); // flowLayoutPanel1.Controls.Add(DataGridview); DataGridview1.DataSource = dt; //DataGridview.AllowPaging = true; //DataGridview.PageSize = PageSize; DataGridview1.DataBind(); // DataGridview.PageIndexChanging += new GridViewPageEventHandler(GridView1_PageIndexChanging); //DataGridview.PageIndexChanging += GridView1_PageIndexChanging; var enumerableTable = (dt as System.ComponentModel.IListSource).GetList(); Chart1.DataBindTable(enumerableTable, "Itemset"); //Chart1.Series["Series1"].XValueMember = "Count"; //Chart1.Series["Series1"].YValueMembers = "Itemset"; //Chart1.DataSource = dt; //Chart1.DataBind(); //Chart ItemsetChart = new Chart(); //ItemsetChart.Series.Add("x"); //ItemsetChart.Series["x"].XValueMember = "Itemset"; //ItemsetChart.Series["x"].YValueMembers = "Count"; //ItemsetChart.DataSource = dt; //ItemsetChart.DataBind(); BAL.Apriori apriori = new BAL.Apriori(lines.ToList()); int k = 1; List <BAL.ItemSet> ItemSets = new List <BAL.ItemSet>(); bool next; do { next = false; var L = apriori.GetItemSet(k, Support, IsFirstItemList: k == 1); if (L.Count > 0) { List <AssociationRule> rules = new List <AssociationRule>(); if (k != 1) { rules = apriori.GetRules(L); } // TableUserControl tableL = new TableUserControl(L, rules); TableUserControl(L, rules); next = true; k++; ItemSets.Add(L); } } while (next); }
//private void DoThings() //{ // int Support = trackBar1.Value; // flowLayoutPanel1.Controls.Clear(); // flowLayoutPanel1.Controls.Add(new TableUserControl(File.ReadAllLines(FileName).ToList())); // Refresh(); // BAL.Apriori apriori = new BAL.Apriori(FileName); // int k = 1; // List<BAL.ItemSet> ItemSets = new List<BAL.ItemSet>(); // bool next; // do // { // next = false; // if (k > 1) // { // List<string> values = new List<string>(); // foreach (var item in ItemSets[ItemSets.Count - 1]) // { // if (item.Value >= Support) // values.Add(item.Key.ToDisplay(" ")); // } // apriori.SetDistinctValues(values); // values = null; // var C = apriori.GetItemSet(k, Support, Candidates: true); // TableUserControl tableC = new TableUserControl(C); // if (C.Count > 0) // { // flowLayoutPanel1.Controls.Add(tableC); // flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Maximum; // Refresh(); // } // //tableC.Dispose(); // } // var L = apriori.GetItemSet(k, Support, IsFirstItemList: k == 1); // TableUserControl tableL = new TableUserControl(L); // if (L.Count > 0) // { // next = true; // k++; // ItemSets.Add(L); // flowLayoutPanel1.Controls.Add(tableL); // flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Maximum; // Refresh(); // } // //tableL.Dispose(); // } while (next); //} private void DoThings() { int Support = 2; if (trackBar1.InvokeRequired) { trackBar1.Invoke(new MethodInvoker(delegate { Support = trackBar1.Value + 1; trackBar1.Enabled = false; } )); } if (flowLayoutPanel1.InvokeRequired) { flowLayoutPanel1.Invoke(new MethodInvoker(delegate { flowLayoutPanel1.Controls.Clear(); flowLayoutPanel1.Controls.Add(new TableUserControl(File.ReadAllLines(FileName).ToList())); } )); } BAL.Apriori apriori = new BAL.Apriori(FileName); int k = 1; List <BAL.ItemSet> ItemSets = new List <BAL.ItemSet>(); bool next; do { next = false; var L = apriori.GetItemSet(k, Support, IsFirstItemList: k == 1); if (L.Count > 0) { List <AssociationRule> rules = new List <AssociationRule>(); if (k != 1) { rules = apriori.GetRules(L); } TableUserControl tableL = new TableUserControl(L, rules); next = true; k++; ItemSets.Add(L); if (flowLayoutPanel1.InvokeRequired) { flowLayoutPanel1.Invoke(new MethodInvoker(delegate { flowLayoutPanel1.Controls.Add(tableL); flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Maximum; } )); } } } while (next); if (trackBar1.InvokeRequired) { trackBar1.Invoke(new MethodInvoker(delegate { trackBar1.Enabled = true; } )); } }