protected override Itemset[] ScanDbAndCountCandidatesSupport(Itemset[] candidates) { foreach (var transaction in _db.Transactions) { if (IsReducted(transaction)) { continue; } bool containsCandidates = false; foreach (var candidate in candidates) { if (ItemsetHelper.IsSubset(transaction.Items, candidate.Items)) { candidate.Support++; containsCandidates = true; } } if (containsCandidates) { continue; } ReduceTransaction(transaction); } return(candidates); }
private void CountSupportForCandidatesInRange(Tuple <int, int> range) { for (int i = range.Item1; i < range.Item2; i++) { if (ItemsetHelper.IsSubset(_actualTransaction.Items, _candidates[i].Items)) { _candidates[i].Support++; } } }
protected virtual Itemset[] ScanDbAndCountCandidatesSupport(Itemset[] candidates) { foreach (var transaction in _db.Transactions) { foreach (var candidate in candidates) { if (ItemsetHelper.IsSubset(transaction.Items, candidate.Items)) { candidate.Support++; } } } return(candidates); }
public void Can_Calculate_SubItemset() { bool result = ItemsetHelper.IsSubset(Itemset.Create(1), Itemset.Create(2)); Assert.AreEqual(false, result); result = ItemsetHelper.IsSubset(Itemset.Create(1, 2), Itemset.Create(2)); Assert.AreEqual(true, result); result = ItemsetHelper.IsSubset(Itemset.Create(1, 2, 3), Itemset.Create(2)); Assert.AreEqual(true, result); result = ItemsetHelper.IsSubset(Itemset.Create(1, 2, 3), Itemset.Create(2, 3)); Assert.AreEqual(true, result); result = ItemsetHelper.IsSubset(Itemset.Create(1, 2, 3), Itemset.Create(2, 3, 4)); Assert.AreEqual(false, result); }