public static VeriToplami AltKumeBul(Veri veriler, int n) { VeriToplami liste = new VeriToplami(); int AltKumeSayisi = (int)Math.Pow(2, Convert.ToInt32(veriler.Count)); for (int i = 0; i < AltKumeSayisi; i++) { if (n == 0 || GetOnCount(i, veriler.Count) == n) { string binary = DecimalToBinary(i, veriler.Count); Veri altkume = new Veri(); for (int bitIndex = 0; bitIndex < veriler.Count; bitIndex++) { if (binary[bitIndex] == '1') { altkume.Add(veriler[bitIndex]); } } //Console.WriteLine("Alt küme sayısı " + altkume.Count()); //Console.WriteLine(altkume); liste.Add(altkume); } } return(liste); }
private void button1_Click(object sender, EventArgs e) { listBox1.Items.Clear(); listBox2.Items.Clear(); SqlConnection con = new SqlConnection(baglan); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = " select * from Movies2"; SqlDataReader dr = cmd.ExecuteReader(); Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >(); while (dr.Read()) { varliklar.KisiFilmler nesne = new varliklar.KisiFilmler(); nesne._CustomerID = dr["CustomerID"].ToString(); nesne._Movie = dr["Movie"].ToString().Trim(); if (dic.ContainsKey(nesne._CustomerID)) { dic[nesne._CustomerID].Add(nesne._Movie); } else { dic.Add(nesne._CustomerID, new List <string>()); dic[nesne._CustomerID].Add(nesne._Movie); } } for (int i = 0; i < dic.Count; i++) { List <string> lll = dic.ElementAt(i).Value; Veri v = new Veri(); foreach (var item in lll) { v.Add(item); } db.Add(v); } varliklar.kisi_film_listesi n = null; List <varliklar.kisi_film_listesi> aa = new List <varliklar.kisi_film_listesi>(); //////////////////////////////////////////////// //varliklar.KisiFilmler nesne = new varliklar.KisiFilmler(); //for (int i = 0; i < customerId.Count; i++) //{ // for (int j = 0; j < movies.Count; j++) // { // if (customerId[i] == customerId[j] ) // { // //nesne._CustomerID = (customerId[i]); // nesne._Movie = movies[j]; // //Customerid_list.Add(nesne._CustomerID); // movie_list.Add(nesne._Movie); // vr.Add(movie_list[j]); // //vr.Add(Customerid_list[j]); // } // } // //vr.Add(nesne._Movie); // //db.Add(vr); // } //for (int i = 0; i < vr.Count; i++) // { // db.Add(new Veri() { } ); // } ////////////////////////////////////////////// //String item1 = "A beautiful mind"; //String item2 = "A Few Good "; //String item3 = "Last of the Mohicans"; //String item4 = "Star wars"; //String item5 = "Star Wars Episode I: The Phantom Menace"; //String item6 = "Saving Private Ryan"; //String item7 = "American Pie"; //String item8 = "Aliens"; //string item1 = "tanju"; //string item2 = "Adnan"; //string item3 = "Vehbi"; //string item4 = "nevzat"; //string item5 = "hulya"; //string item6 = "annem"; //string item7 = "vehbi"; //string item8 = "hakan"; //db.Add(new Veri() { item1, item2 }); //db.Add(new Veri() { item1, item2, item3, item4 }); //db.Add(new Veri() { item3, item4, item2, item5 }); //db.Add(new Veri() { item2, item1, item7 }); //db.Add(new Veri() { item1, item6, item8 }); //Veri uniqueItems = db.GetUniqueItems(); VeriToplami L = Apiori_1(db, Convert.ToDouble(textBox1.Text)); // Console.WriteLine("<br/>" + L.Count + " itemsets in L<br/>"); listBox1.Items.Clear(); foreach (Veri i in L) { listBox1.Items.Add(i + "\n"); //Console.WriteLine(i + "<br/>"); } //test mining List <Birliktelik> TumKurallar = BirlitelikBul(db, L, Convert.ToDouble(textBox2.Text)); //Console.WriteLine("<br/>" + allRules.Count + " rules<br/>"); //listBox2.Width = 1300; listBox2.Items.Clear(); foreach (Birliktelik Kural in TumKurallar) { listBox2.Items.Add(Kural + "\n"); } con.Close(); return; }