static List <List <Item> > Apriori(Database DB, float minSupport, float minConfidence) { List <List <Item> > result = new List <List <Item> >(); //Scanning DB once to get frequent 1 - itemsets result.Add(GetL1FrequentItems(DB, minSupport)); for (int i = 1; result[i - 1].Count != 0; i++) { List <Item> candidates = new List <Item>(); candidates = GenerateCandidates(result[i - 1], DB); List <Item> LiResult = new List <Item>(); foreach (Item item in candidates) { if (item.Support >= minSupport) { LiResult.Add(item); } } result.Add(LiResult); } for (int i = 0; i < result.Count; i++) { Console.WriteLine("Frequent transaction of length " + (i + 1)); foreach (var TList in result[i]) { Console.WriteLine(TList.ToString() + " with support = " + TList.Support); } } return(result); }
internal static void Main() { //// adding element + AutoGrow() TList<int> somelist = new TList<int>(2); somelist.Add(1); somelist.Add(2); somelist.Add(3); //// removing element by index somelist.RemoveAt(1); //// inserting element at given position somelist.InsertAt(0, 0); //// accessing element by index (I feel so sleepy that I dont't see 2) for (int i = 0; i < somelist.Count; i++) { Console.WriteLine(somelist[i]); } //// finding element by its value Console.WriteLine(somelist.Contains(3)); ////ToString override Console.WriteLine(somelist.ToString()); //// Min and max value int minValue = somelist.Min(); int maxValue = somelist.Max(); Console.WriteLine("MinValue = {0}\nMaxValue = {1}\n", minValue, maxValue); ////Clear list - List is empty & nothing is printed somelist.Clear(); for (int i = 0; i < somelist.Count; i++) { Console.WriteLine(somelist[i]); } }