public void generateFrecuentItemsets(double threshold, string region) { TimeSpan stop; TimeSpan start = new TimeSpan(DateTime.Now.Ticks); if (!region.Equals("TODO")) { foreach (int t in Transactions.Keys) { if (Clients[Transactions[t].ClientCode].Departament.Equals(region)) { FilteredTransactions.Add(Transactions[t].Code, Transactions[t]); } } } else { FilteredTransactions = Transactions; } if (region.Equals("VALLE DEL CAUCA") || region.Equals("BOGOTA") || region.Equals("CUNDINAMARCA") || region.Equals("RISARALDA") || region.Equals("TODO")) { PrunningClientsAndTransactions(); } else { TransactionsPrunned = FilteredTransactions; } stop = new TimeSpan(DateTime.Now.Ticks); Console.WriteLine("Time prunning clients and transactions: " + stop.Subtract(start).TotalSeconds + " segundos"); List <List <int> > transactions = TransactionsPrunned.Select(t => t.Value.Items).ToList(); List <int[]> itemsets = GenerateItemSet_BruteForce(1); List <int[]> frecuentIS = Apriori.GenerateAllFrecuentItemsets(itemsets, transactions, threshold).ToList(); listadoIF = auxiliarIF(frecuentIS, transactions); Console.WriteLine("Number of frecuent itemsets: " + frecuentIS.Count); List <Itemset> FIS = new List <Itemset>(); for (int i = 0; i < frecuentIS.Count; i++) { int[] actual = frecuentIS.ElementAt(i); List <Item> theItems = new List <Item>(); for (int j = 0; j < actual.Length; j++) { Item theItem = Items[actual[j]]; theItems.Add(theItem); } double averageP = theItems.Average(it => it.AveragePrice); double averageC = theItems.Average(it => Convert.ToDouble(it.Clasification)); Itemset nuevoItemset = new Itemset(theItems, averageP, averageC); FIS.Add(nuevoItemset); } FrecuentItemsets = FIS; }