<commit_before>"""Module for generating candidate k-itemsets."""

def generate_candidate_one_itemset(transactions):
    """Generates candidate 1-itemset."""
    return {frozenset([item, item]) for item in set.union(*transactions)}

def generate_candidate_itemsets(itemsets, itemset_sups):
    """Generates candidate k-itemsets."""
    candidate_itemsets = set()
    for itemset1 in itemsets:
        for itemset2 in itemsets:
            # Find the symmetric difference to ensure only the first k-2 items match.
            itemlist_diff = list(itemset1 ^ itemset2)
            if len(itemlist_diff) == 2 and itemlist_diff[0][0] != itemlist_diff[1][0]: 
                candidate_itemsets.add(itemset1 | itemset2)
    return candidate_itemsets<commit_msg>Improved efficiency of generate_candidate_itemsets<commit_after>"""Module for generating candidate k-itemsets."""

from itertools import combinations

def generate_candidate_one_itemset(transactions):
    """Generates candidate 1-itemset."""
    return {frozenset([item, item]) for item in set.union(*transactions)}

def generate_candidate_itemsets(itemsets):
    """Generates candidate k-itemsets."""
    candidate_itemsets = set()
    for itemset1, itemset2 in combinations(itemsets, 2):
        # Find the symmetric difference to ensure only the first k-2 items match.
        itemlist_diff = list(itemset1 ^ itemset2)
        if len(itemlist_diff) == 2 and itemlist_diff[0][0] != itemlist_diff[1][0]:
            candidate_itemsets.add(itemset1 | itemset2)
    return candidate_itemsets
{'fraction_non_alphanumeric': 0.09967637540453074, 'fraction_numerical': 0.017475728155339806, 'mean_word_length': 4.102310231023102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2204846', 'n_tokens_mistral': 456, 'n_tokens_neox': 450, 'n_words': 119}