王家林老师人工智能AI 第26课:使用Apriori对美食店的消费者进行美食推荐 老师微信13928463918

版权声明:王家林大咖2018年新书《SPARK大数据商业实战三部曲》清华大学出版,清华大学出版社官方旗舰店(天猫)https://qhdx.tmall.com/?spm=a220o.1000855.1997427721.d4918089.4b2a2e5dT6bUsM https://blog.csdn.net/duan_zhihua/article/details/81406900

王家林老师人工智能AI 第26课:使用Apriori对美食店的消费者进行美食推荐 老师微信13928463918

美食店交易清单文件Market_Basket_Optimisation.csv的部分记录:

shrimp,almonds,avocado,vegetables mix,green grapes,whole weat flour,yams,cottage cheese,energy drink,tomato juice,low fat yogurt,green tea,honey,salad,mineral water,salmon,antioxydant juice,frozen smoothie,spinach,olive oil
burgers,meatballs,eggs
chutney
turkey,avocado
mineral water,milk,energy bar,whole wheat rice,green tea
low fat yogurt
whole wheat pasta,french fries
soup,light cream,shallot
frozen vegetables,spaghetti,green tea
french fries
........

apriori的代码:

# Apriori

# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

# Data Preprocessing
dataset = pd.read_csv('Market_Basket_Optimisation.csv', header = None)
transactions = []
for i in range(0, 7501):
    transactions.append([str(dataset.values[i,j]) for j in range(0, 20)])

# Training Apriori on the dataset
from apyori import apriori
rules = apriori(transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)

# Visualising the results
results = list(rules)

apyori的代码:

#!/usr/bin/env python

"""
a simple implementation of Apriori algorithm by Python.
"""

import sys
import csv
import argparse
import json
import os
from collections import namedtuple
from itertools import combinations
from itertools import chain



################################################################################
# Data structures.
################################################################################
class TransactionManager(object):
    """
    Transaction managers.
    """

    def __init__(self, transactions):
        """
        Initialize.

        Arguments:
            transactions -- A transaction iterable object
                            (eg. [['A', 'B'], ['B', 'C']]).
        """
        self.__num_transaction = 0
        self.__items = []
        self.__transaction_index_map = {}

        for transaction in transactions:
            self.add_transaction(transaction)

    def add_transaction(self, transaction):
        """
        Add a transaction.

        Arguments:
            transaction -- A transaction as an iterable object (eg. ['A', 'B']).
        """
        for item in transaction:
            if item not in self.__transaction_index_map:
                self.__items.append(item)
                self.__transaction_index_map[item] = set()
            self.__transaction_index_map[item].add(self.__num_transaction)
        self.__num_transaction += 1

    def calc_support(self, items):
        """
        Returns a support for items.

        Arguments:
            items -- Items as an iterable object (eg. ['A', 'B']).
        """
        # Empty items is supported by all transactions.
        if not items:
            return 1.0

        # Empty transactions supports no items.
        if not self.num_transaction:
            return 0.0

        # Create the transaction index intersection.
        sum_indexes = None
        for item in items:
            indexes = self.__transaction_index_map.get(item)
            if indexes is None:
                # No support for any set that contains a not existing item.
                return 0.0

            if sum_indexes is None:
                # Assign the indexes on the first time.
                sum_indexes = indexes
            else:
                # Calculate the intersection on not the first time.
                sum_indexes = sum_indexes.intersection(indexes)

        # Calculate and return the support.
        return float(len(sum_indexes)) / self.__num_transaction

    def initial_candidates(self):
        """
        Returns the initial candidates.
        """
        return [frozenset([item]) for item in self.items]

    @property
    def num_transaction(self):
        """
        Returns the number of transactions.
        """
        return self.__num_transaction

    @property
    def items(self):
        """
        Returns the item list that the transaction is consisted of.
        """
        return sorted(self.__items)

    @staticmethod
    def create(transactions):
        """
        Create the TransactionManager with a transaction instance.
        If the given instance is a TransactionManager, this returns itself.
        """
        if isinstance(transactions, TransactionManager):
            return transactions
        return TransactionManager(transactions)


# Ignore name errors because these names are namedtuples.
SupportRecord = namedtuple( # pylint: disable=C0103
    'SupportRecord', ('items', 'support'))
RelationRecord = namedtuple( # pylint: disable=C0103
    'RelationRecord', SupportRecord._fields + ('ordered_statistics',))
OrderedStatistic = namedtuple( # pylint: disable=C0103
    'OrderedStatistic', ('items_base', 'items_add', 'confidence', 'lift',))


################################################################################
# Inner functions.
################################################################################
def create_next_candidates(prev_candidates, length):
    """
    Returns the apriori candidates as a list.

    Arguments:
        prev_candidates -- Previous candidates as a list.
        length -- The lengths of the next candidates.
    """
    # Solve the items.
    item_set = set()
    for candidate in prev_candidates:
        for item in candidate:
            item_set.add(item)
    items = sorted(item_set)

    # Create the temporary candidates. These will be filtered below.
    tmp_next_candidates = (frozenset(x) for x in combinations(items, length))

    # Return all the candidates if the length of the next candidates is 2
    # because their subsets are the same as items.
    if length < 3:
        return list(tmp_next_candidates)

    # Filter candidates that all of their subsets are
    # in the previous candidates.
    next_candidates = [
        candidate for candidate in tmp_next_candidates
        if all(
            True if frozenset(x) in prev_candidates else False
            for x in combinations(candidate, length - 1))
    ]
    return next_candidates


def gen_support_records(transaction_manager, min_support, **kwargs):
    """
    Returns a generator of support records with given transactions.

    Arguments:
        transaction_manager -- Transactions as a TransactionManager instance.
        min_support -- A minimum support (float).

    Keyword arguments:
        max_length -- The maximum length of relations (integer).
    """
    # Parse arguments.
    max_length = kwargs.get('max_length')

    # For testing.
    _create_next_candidates = kwargs.get(
        '_create_next_candidates', create_next_candidates)

    # Process.
    candidates = transaction_manager.initial_candidates()
    length = 1
    while candidates:
        relations = set()
        for relation_candidate in candidates:
            support = transaction_manager.calc_support(relation_candidate)
            if support < min_support:
                continue
            candidate_set = frozenset(relation_candidate)
            relations.add(candidate_set)
            yield SupportRecord(candidate_set, support)
        length += 1
        if max_length and length > max_length:
            break
        candidates = _create_next_candidates(relations, length)


def gen_ordered_statistics(transaction_manager, record):
    """
    Returns a generator of ordered statistics as OrderedStatistic instances.

    Arguments:
        transaction_manager -- Transactions as a TransactionManager instance.
        record -- A support record as a SupportRecord instance.
    """
    items = record.items
    for combination_set in combinations(sorted(items), len(items) - 1):
        items_base = frozenset(combination_set)
        items_add = frozenset(items.difference(items_base))
        confidence = (
            record.support / transaction_manager.calc_support(items_base))
        lift = confidence / transaction_manager.calc_support(items_add)
        yield OrderedStatistic(
            frozenset(items_base), frozenset(items_add), confidence, lift)


def filter_ordered_statistics(ordered_statistics, **kwargs):
    """
    Filter OrderedStatistic objects.

    Arguments:
        ordered_statistics -- A OrderedStatistic iterable object.

    Keyword arguments:
        min_confidence -- The minimum confidence of relations (float).
        min_lift -- The minimum lift of relations (float).
    """
    min_confidence = kwargs.get('min_confidence', 0.0)
    min_lift = kwargs.get('min_lift', 0.0)

    for ordered_statistic in ordered_statistics:
        if ordered_statistic.confidence < min_confidence:
            continue
        if ordered_statistic.lift < min_lift:
            continue
        yield ordered_statistic


################################################################################
# API function.
################################################################################
def apriori(transactions, **kwargs):
    """
    Executes Apriori algorithm and returns a RelationRecord generator.

    Arguments:
        transactions -- A transaction iterable object
                        (eg. [['A', 'B'], ['B', 'C']]).

    Keyword arguments:
        min_support -- The minimum support of relations (float).
        min_confidence -- The minimum confidence of relations (float).
        min_lift -- The minimum lift of relations (float).
        max_length -- The maximum length of the relation (integer).
    """
    # Parse the arguments.
    min_support = kwargs.get('min_support', 0.1)
    min_confidence = kwargs.get('min_confidence', 0.0)
    min_lift = kwargs.get('min_lift', 0.0)
    max_length = kwargs.get('max_length', None)

    # Check arguments.
    if min_support <= 0:
        raise ValueError('minimum support must be > 0')

    # For testing.
    _gen_support_records = kwargs.get(
        '_gen_support_records', gen_support_records)
    _gen_ordered_statistics = kwargs.get(
        '_gen_ordered_statistics', gen_ordered_statistics)
    _filter_ordered_statistics = kwargs.get(
        '_filter_ordered_statistics', filter_ordered_statistics)

    # Calculate supports.
    transaction_manager = TransactionManager.create(transactions)
    support_records = _gen_support_records(
        transaction_manager, min_support, max_length=max_length)

    # Calculate ordered stats.
    for support_record in support_records:
        ordered_statistics = list(
            _filter_ordered_statistics(
                _gen_ordered_statistics(transaction_manager, support_record),
                min_confidence=min_confidence,
                min_lift=min_lift,
            )
        )
        if not ordered_statistics:
            continue
        yield RelationRecord(
            support_record.items, support_record.support, ordered_statistics)


################################################################################
# Application functions.
################################################################################
def parse_args(argv):
    """
    Parse commandline arguments.

    Arguments:
        argv -- An argument list without the program name.
    """
    output_funcs = {
        'json': dump_as_json,
        'tsv': dump_as_two_item_tsv,
    }
    default_output_func_key = 'json'

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-v', '--version', action='version',
        version='%(prog)s {0}'.format(__version__))
    parser.add_argument(
        'input', metavar='inpath', nargs='*',
        help='Input transaction file (default: stdin).',
        type=argparse.FileType('r'), default=[sys.stdin])
    parser.add_argument(
        '-o', '--output', metavar='outpath',
        help='Output file (default: stdout).',
        type=argparse.FileType('w'), default=sys.stdout)
    parser.add_argument(
        '-l', '--max-length', metavar='int',
        help='Max length of relations (default: infinite).',
        type=int, default=None)
    parser.add_argument(
        '-s', '--min-support', metavar='float',
        help='Minimum support ratio (must be > 0, default: 0.1).',
        type=float, default=0.1)
    parser.add_argument(
        '-c', '--min-confidence', metavar='float',
        help='Minimum confidence (default: 0.5).',
        type=float, default=0.5)
    parser.add_argument(
        '-t', '--min-lift', metavar='float',
        help='Minimum lift (default: 0.0).',
        type=float, default=0.0)
    parser.add_argument(
        '-d', '--delimiter', metavar='str',
        help='Delimiter for items of transactions (default: tab).',
        type=str, default='\t')
    parser.add_argument(
        '-f', '--out-format', metavar='str',
        help='Output format ({0}; default: {1}).'.format(
            ', '.join(output_funcs.keys()), default_output_func_key),
        type=str, choices=output_funcs.keys(), default=default_output_func_key)
    args = parser.parse_args(argv)

    args.output_func = output_funcs[args.out_format]
    return args


def load_transactions(input_file, **kwargs):
    """
    Load transactions and returns a generator for transactions.

    Arguments:
        input_file -- An input file.

    Keyword arguments:
        delimiter -- The delimiter of the transaction.
    """
    delimiter = kwargs.get('delimiter', '\t')
    for transaction in csv.reader(input_file, delimiter=delimiter):
        yield transaction if transaction else ['']


def dump_as_json(record, output_file):
    """
    Dump an relation record as a json value.

    Arguments:
        record -- A RelationRecord instance to dump.
        output_file -- A file to output.
    """
    def default_func(value):
        """
        Default conversion for JSON value.
        """
        if isinstance(value, frozenset):
            return sorted(value)
        raise TypeError(repr(value) + " is not JSON serializable")

    converted_record = record._replace(
        ordered_statistics=[x._asdict() for x in record.ordered_statistics])
    json.dump(
        converted_record._asdict(), output_file,
        default=default_func, ensure_ascii=False)
    output_file.write(os.linesep)


def dump_as_two_item_tsv(record, output_file):
    """
    Dump a relation record as TSV only for 2 item relations.

    Arguments:
        record -- A RelationRecord instance to dump.
        output_file -- A file to output.
    """
    for ordered_stats in record.ordered_statistics:
        if len(ordered_stats.items_base) != 1:
            continue
        if len(ordered_stats.items_add) != 1:
            continue
        output_file.write('{0}\t{1}\t{2:.8f}\t{3:.8f}\t{4:.8f}{5}'.format(
            list(ordered_stats.items_base)[0], list(ordered_stats.items_add)[0],
            record.support, ordered_stats.confidence, ordered_stats.lift,
            os.linesep))


def main(**kwargs):
    """
    Executes Apriori algorithm and print its result.
    """
    # For tests.
    _parse_args = kwargs.get('_parse_args', parse_args)
    _load_transactions = kwargs.get('_load_transactions', load_transactions)
    _apriori = kwargs.get('_apriori', apriori)

    args = _parse_args(sys.argv[1:])
    transactions = _load_transactions(
        chain(*args.input), delimiter=args.delimiter)
    result = _apriori(
        transactions,
        max_length=args.max_length,
        min_support=args.min_support,
        min_confidence=args.min_confidence)
    for record in result:
        args.output_func(record, args.output)


if __name__ == '__main__':
    main()

apyori.py的运行结果为:

G:\ProgramData\Anaconda3\python.exe D:/PycharmProjects/SparkAI2018_spyder/Apriori_20180803/apriori.py
[RelationRecord(items=frozenset({'light cream', 'chicken'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'light cream'}), items_add=frozenset({'chicken'}), confidence=0.29059829059829057, lift=4.84395061728395)]), RelationRecord(items=frozenset({'mushroom cream sauce', 'escalope'}), support=0.005732568990801226, ordered_statistics=[OrderedStatistic(items_base=frozenset({'mushroom cream sauce'}), items_add=frozenset({'escalope'}), confidence=0.3006993006993007, lift=3.790832696715049)]), RelationRecord(items=frozenset({'pasta', 'escalope'}), support=0.005865884548726837, ordered_statistics=[OrderedStatistic(items_base=frozenset({'pasta'}), items_add=frozenset({'escalope'}), confidence=0.3728813559322034, lift=4.700811850163794)]), RelationRecord(items=frozenset({'fromage blanc', 'honey'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'fromage blanc'}), items_add=frozenset({'honey'}), confidence=0.2450980392156863, lift=5.164270764485569)]), RelationRecord(items=frozenset({'ground beef', 'herb & pepper'}), support=0.015997866951073192, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper'}), items_add=frozenset({'ground beef'}), confidence=0.3234501347708895, lift=3.2919938411349285)]), RelationRecord(items=frozenset({'ground beef', 'tomato sauce'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'tomato sauce'}), items_add=frozenset({'ground beef'}), confidence=0.3773584905660377, lift=3.840659481324083)]), RelationRecord(items=frozenset({'olive oil', 'light cream'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'light cream'}), items_add=frozenset({'olive oil'}), confidence=0.20512820512820515, lift=3.1147098515519573)]), RelationRecord(items=frozenset({'whole wheat pasta', 'olive oil'}), support=0.007998933475536596, ordered_statistics=[OrderedStatistic(items_base=frozenset({'whole wheat pasta'}), items_add=frozenset({'olive oil'}), confidence=0.2714932126696833, lift=4.122410097642296)]), RelationRecord(items=frozenset({'pasta', 'shrimp'}), support=0.005065991201173177, ordered_statistics=[OrderedStatistic(items_base=frozenset({'pasta'}), items_add=frozenset({'shrimp'}), confidence=0.3220338983050847, lift=4.506672147735896)]), RelationRecord(items=frozenset({'avocado', 'milk', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'avocado', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.41666666666666663, lift=3.215449245541838)]), RelationRecord(items=frozenset({'milk', 'burgers', 'cake'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'cake'}), items_add=frozenset({'burgers'}), confidence=0.27999999999999997, lift=3.211437308868501)]), RelationRecord(items=frozenset({'turkey', 'burgers', 'chocolate'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'turkey', 'chocolate'}), items_add=frozenset({'burgers'}), confidence=0.27058823529411763, lift=3.1034898363014927)]), RelationRecord(items=frozenset({'turkey', 'milk', 'burgers'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'turkey', 'milk'}), items_add=frozenset({'burgers'}), confidence=0.2823529411764706, lift=3.2384241770102533)]), RelationRecord(items=frozenset({'frozen vegetables', 'tomatoes', 'cake'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'cake'}), items_add=frozenset({'tomatoes'}), confidence=0.2987012987012987, lift=4.367560314928736), OrderedStatistic(items_base=frozenset({'tomatoes', 'cake'}), items_add=frozenset({'frozen vegetables'}), confidence=0.36507936507936506, lift=3.8300144300144296)]), RelationRecord(items=frozenset({'ground beef', 'spaghetti', 'cereals'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'cereals'}), items_add=frozenset({'spaghetti'}), confidence=0.6764705882352942, lift=3.8853031258445188), OrderedStatistic(items_base=frozenset({'spaghetti', 'cereals'}), items_add=frozenset({'ground beef'}), confidence=0.45999999999999996, lift=4.681763907734057)]), RelationRecord(items=frozenset({'ground beef', 'milk', 'chicken'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'chicken'}), items_add=frozenset({'milk'}), confidence=0.40845070422535207, lift=3.152046020981858)]), RelationRecord(items=frozenset({'nan', 'light cream', 'chicken'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'light cream'}), items_add=frozenset({'chicken'}), confidence=0.29059829059829057, lift=4.84395061728395)]), RelationRecord(items=frozenset({'milk', 'olive oil', 'chicken'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'chicken'}), items_add=frozenset({'olive oil'}), confidence=0.24324324324324323, lift=3.693456614509246), OrderedStatistic(items_base=frozenset({'olive oil', 'chicken'}), items_add=frozenset({'milk'}), confidence=0.5, lift=3.858539094650206), OrderedStatistic(items_base=frozenset({'milk', 'olive oil'}), items_add=frozenset({'chicken'}), confidence=0.2109375, lift=3.51609375)]), RelationRecord(items=frozenset({'olive oil', 'chicken', 'spaghetti'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'chicken', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20155038759689922, lift=3.0603835169318647)]), RelationRecord(items=frozenset({'frozen vegetables', 'chocolate', 'shrimp'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate'}), items_add=frozenset({'shrimp'}), confidence=0.23255813953488375, lift=3.2545123221103784), OrderedStatistic(items_base=frozenset({'chocolate', 'shrimp'}), items_add=frozenset({'frozen vegetables'}), confidence=0.29629629629629634, lift=3.1084175084175087)]), RelationRecord(items=frozenset({'ground beef', 'chocolate', 'herb & pepper'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'chocolate'}), items_add=frozenset({'ground beef'}), confidence=0.4411764705882354, lift=4.4901827759597746)]), RelationRecord(items=frozenset({'milk', 'chocolate', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'chocolate', 'soup'}), items_add=frozenset({'milk'}), confidence=0.3947368421052632, lift=3.0462150747238472)]), RelationRecord(items=frozenset({'ground beef', 'cooking oil', 'spaghetti'}), support=0.004799360085321957, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'cooking oil'}), items_add=frozenset({'spaghetti'}), confidence=0.5714285714285714, lift=3.2819951870487856), OrderedStatistic(items_base=frozenset({'cooking oil', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3025210084033613, lift=3.0789824749438446)]), RelationRecord(items=frozenset({'ground beef', 'herb & pepper', 'eggs'}), support=0.0041327822956939075, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'eggs'}), items_add=frozenset({'herb & pepper'}), confidence=0.2066666666666667, lift=4.178454627133872), OrderedStatistic(items_base=frozenset({'herb & pepper', 'eggs'}), items_add=frozenset({'ground beef'}), confidence=0.3297872340425532, lift=3.3564912381997174)]), RelationRecord(items=frozenset({'spaghetti', 'red wine', 'eggs'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'red wine', 'eggs'}), items_add=frozenset({'spaghetti'}), confidence=0.5283018867924528, lift=3.0342974370828397)]), RelationRecord(items=frozenset({'nan', 'mushroom cream sauce', 'escalope'}), support=0.005732568990801226, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'mushroom cream sauce'}), items_add=frozenset({'escalope'}), confidence=0.3006993006993007, lift=3.790832696715049)]), RelationRecord(items=frozenset({'nan', 'pasta', 'escalope'}), support=0.005865884548726837, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'pasta'}), items_add=frozenset({'escalope'}), confidence=0.3728813559322034, lift=4.700811850163794)]), RelationRecord(items=frozenset({'ground beef', 'herb & pepper', 'french fries'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'french fries'}), items_add=frozenset({'herb & pepper'}), confidence=0.23076923076923078, lift=4.665768194070081), OrderedStatistic(items_base=frozenset({'herb & pepper', 'french fries'}), items_add=frozenset({'ground beef'}), confidence=0.46153846153846156, lift=4.697421981004071)]), RelationRecord(items=frozenset({'nan', 'fromage blanc', 'honey'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'fromage blanc'}), items_add=frozenset({'honey'}), confidence=0.2450980392156863, lift=5.164270764485569)]), RelationRecord(items=frozenset({'frozen vegetables', 'green tea', 'tomatoes'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'green tea'}), items_add=frozenset({'tomatoes'}), confidence=0.2314814814814815, lift=3.38468341635983)]), RelationRecord(items=frozenset({'frozen vegetables', 'ground beef', 'spaghetti'}), support=0.008665511265164644, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.31100478468899523, lift=3.165328208890303)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'olive oil'}), support=0.004799360085321957, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk'}), items_add=frozenset({'olive oil'}), confidence=0.20338983050847456, lift=3.088314005352364), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'olive oil'}), items_add=frozenset({'milk'}), confidence=0.4235294117647058, lift=3.2684095860566447)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'soup'}), items_add=frozenset({'milk'}), confidence=0.5, lift=3.858539094650206)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'tomatoes'}), support=0.0041327822956939075, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'tomatoes'}), items_add=frozenset({'frozen vegetables'}), confidence=0.29523809523809524, lift=3.0973160173160172)]), RelationRecord(items=frozenset({'frozen vegetables', 'shrimp', 'mineral water'}), support=0.007199040127982935, ordered_statistics=[OrderedStatistic(items_base=frozenset({'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.30508474576271183, lift=3.200616332819722)]), RelationRecord(items=frozenset({'frozen vegetables', 'olive oil', 'spaghetti'}), support=0.005732568990801226, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20574162679425836, lift=3.1240241752707125)]), RelationRecord(items=frozenset({'frozen vegetables', 'spaghetti', 'shrimp'}), support=0.005999200106652446, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti'}), items_add=frozenset({'shrimp'}), confidence=0.21531100478468898, lift=3.0131489680782684)]), RelationRecord(items=frozenset({'frozen vegetables', 'tomatoes', 'shrimp'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'shrimp'}), items_add=frozenset({'tomatoes'}), confidence=0.24000000000000002, lift=3.5092397660818717), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'tomatoes'}), items_add=frozenset({'shrimp'}), confidence=0.2479338842975207, lift=3.4696866905143704), OrderedStatistic(items_base=frozenset({'tomatoes', 'shrimp'}), items_add=frozenset({'frozen vegetables'}), confidence=0.35714285714285715, lift=3.7467532467532467)]), RelationRecord(items=frozenset({'frozen vegetables', 'tomatoes', 'spaghetti'}), support=0.006665777896280496, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti'}), items_add=frozenset({'tomatoes'}), confidence=0.23923444976076558, lift=3.4980460188216425), OrderedStatistic(items_base=frozenset({'tomatoes', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3184713375796179, lift=3.341053850607991)]), RelationRecord(items=frozenset({'ground beef', 'grated cheese', 'spaghetti'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'grated cheese', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3225806451612903, lift=3.283144395325426)]), RelationRecord(items=frozenset({'green tea', 'ground beef', 'tomatoes'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'green tea', 'ground beef'}), items_add=frozenset({'tomatoes'}), confidence=0.2072072072072072, lift=3.0297490472929067)]), RelationRecord(items=frozenset({'ground beef', 'milk', 'herb & pepper'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'milk'}), items_add=frozenset({'ground beef'}), confidence=0.3913043478260869, lift=3.9825968969382335)]), RelationRecord(items=frozenset({'ground beef', 'herb & pepper', 'mineral water'}), support=0.006665777896280496, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.39062500000000006, lift=3.975682666214383)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'herb & pepper'}), support=0.015997866951073192, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan'}), items_add=frozenset({'ground beef'}), confidence=0.3234501347708895, lift=3.2919938411349285)]), RelationRecord(items=frozenset({'ground beef', 'herb & pepper', 'spaghetti'}), support=0.006399146780429276, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3934426229508197, lift=4.004359721511667)]), RelationRecord(items=frozenset({'ground beef', 'milk', 'olive oil'}), support=0.004932675643247567, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'milk'}), items_add=frozenset({'olive oil'}), confidence=0.22424242424242427, lift=3.40494417862839)]), RelationRecord(items=frozenset({'ground beef', 'milk', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'soup'}), items_add=frozenset({'milk'}), confidence=0.4109589041095891, lift=3.1714019956029094)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'tomato sauce'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'tomato sauce'}), items_add=frozenset({'ground beef'}), confidence=0.3773584905660377, lift=3.840659481324083)]), RelationRecord(items=frozenset({'ground beef', 'pepper', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'pepper', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.33783783783783783, lift=3.4384282518610876)]), RelationRecord(items=frozenset({'ground beef', 'spaghetti', 'shrimp'}), support=0.005999200106652446, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'shrimp'}), items_add=frozenset({'spaghetti'}), confidence=0.5232558139534884, lift=3.005315360233627)]), RelationRecord(items=frozenset({'ground beef', 'tomato sauce', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'tomato sauce'}), items_add=frozenset({'spaghetti'}), confidence=0.5750000000000001, lift=3.3025076569678413), OrderedStatistic(items_base=frozenset({'tomato sauce', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.4893617021276596, lift=4.980599901844742)]), RelationRecord(items=frozenset({'olive oil', 'nan', 'light cream'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'light cream'}), items_add=frozenset({'olive oil'}), confidence=0.20512820512820515, lift=3.1147098515519573)]), RelationRecord(items=frozenset({'milk', 'olive oil', 'shrimp'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'olive oil', 'shrimp'}), items_add=frozenset({'milk'}), confidence=0.3934426229508197, lift=3.0362274843149164)]), RelationRecord(items=frozenset({'milk', 'olive oil', 'soup'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'olive oil'}), items_add=frozenset({'soup'}), confidence=0.2109375, lift=4.174781497361478), OrderedStatistic(items_base=frozenset({'milk', 'soup'}), items_add=frozenset({'olive oil'}), confidence=0.23684210526315788, lift=3.5962603878116344), OrderedStatistic(items_base=frozenset({'olive oil', 'soup'}), items_add=frozenset({'milk'}), confidence=0.4029850746268656, lift=3.1098673300165833)]), RelationRecord(items=frozenset({'milk', 'olive oil', 'spaghetti'}), support=0.007199040127982935, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20300751879699247, lift=3.0825089038385434)]), RelationRecord(items=frozenset({'milk', 'tomatoes', 'soup'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'milk', 'tomatoes'}), items_add=frozenset({'soup'}), confidence=0.21904761904761905, lift=4.335293378565146), OrderedStatistic(items_base=frozenset({'tomatoes', 'soup'}), items_add=frozenset({'milk'}), confidence=0.44230769230769235, lift=3.4133230452674903)]), RelationRecord(items=frozenset({'whole wheat pasta', 'milk', 'spaghetti'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'whole wheat pasta', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.4545454545454546, lift=3.5077628133183696)]), RelationRecord(items=frozenset({'soup', 'olive oil', 'mineral water'}), support=0.005199306759098787, ordered_statistics=[OrderedStatistic(items_base=frozenset({'soup', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.22543352601156072, lift=3.4230301186492245)]), RelationRecord(items=frozenset({'whole wheat pasta', 'olive oil', 'mineral water'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'whole wheat pasta', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.4027777777777778, lift=6.115862573099416)]), RelationRecord(items=frozenset({'nan', 'olive oil', 'whole wheat pasta'}), support=0.007998933475536596, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'whole wheat pasta'}), items_add=frozenset({'olive oil'}), confidence=0.2714932126696833, lift=4.122410097642296)]), RelationRecord(items=frozenset({'nan', 'pasta', 'shrimp'}), support=0.005065991201173177, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'pasta'}), items_add=frozenset({'shrimp'}), confidence=0.3220338983050847, lift=4.506672147735896)]), RelationRecord(items=frozenset({'olive oil', 'pancakes', 'spaghetti'}), support=0.005065991201173177, ordered_statistics=[OrderedStatistic(items_base=frozenset({'pancakes', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20105820105820105, lift=3.0529100529100526)]), RelationRecord(items=frozenset({'olive oil', 'tomatoes', 'spaghetti'}), support=0.004399413411545127, ordered_statistics=[OrderedStatistic(items_base=frozenset({'olive oil', 'tomatoes'}), items_add=frozenset({'spaghetti'}), confidence=0.6111111111111112, lift=3.5099115194827295), OrderedStatistic(items_base=frozenset({'tomatoes', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.21019108280254778, lift=3.19158565202816)]), RelationRecord(items=frozenset({'whole wheat rice', 'tomatoes', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'whole wheat rice', 'spaghetti'}), items_add=frozenset({'tomatoes'}), confidence=0.2169811320754717, lift=3.1726617382029496)]), RelationRecord(items=frozenset({'avocado', 'milk', 'nan', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'avocado', 'nan', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.41666666666666663, lift=3.215449245541838)]), RelationRecord(items=frozenset({'milk', 'burgers', 'nan', 'cake'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'cake'}), items_add=frozenset({'burgers'}), confidence=0.27999999999999997, lift=3.211437308868501)]), RelationRecord(items=frozenset({'turkey', 'nan', 'burgers', 'chocolate'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'turkey', 'nan', 'chocolate'}), items_add=frozenset({'burgers'}), confidence=0.27058823529411763, lift=3.1034898363014927)]), RelationRecord(items=frozenset({'turkey', 'milk', 'burgers', 'nan'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'turkey', 'nan', 'milk'}), items_add=frozenset({'burgers'}), confidence=0.2823529411764706, lift=3.2384241770102533)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'tomatoes', 'cake'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'cake'}), items_add=frozenset({'tomatoes'}), confidence=0.2987012987012987, lift=4.367560314928736), OrderedStatistic(items_base=frozenset({'nan', 'tomatoes', 'cake'}), items_add=frozenset({'frozen vegetables'}), confidence=0.36507936507936506, lift=3.8300144300144296)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'spaghetti', 'cereals'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'cereals'}), items_add=frozenset({'spaghetti'}), confidence=0.6764705882352942, lift=3.8853031258445188), OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'cereals'}), items_add=frozenset({'ground beef'}), confidence=0.45999999999999996, lift=4.681763907734057)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'milk', 'chicken'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'chicken'}), items_add=frozenset({'milk'}), confidence=0.40845070422535207, lift=3.152046020981858)]), RelationRecord(items=frozenset({'nan', 'milk', 'olive oil', 'chicken'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'chicken'}), items_add=frozenset({'olive oil'}), confidence=0.24324324324324323, lift=3.693456614509246), OrderedStatistic(items_base=frozenset({'nan', 'olive oil', 'chicken'}), items_add=frozenset({'milk'}), confidence=0.5, lift=3.858539094650206), OrderedStatistic(items_base=frozenset({'nan', 'milk', 'olive oil'}), items_add=frozenset({'chicken'}), confidence=0.2109375, lift=3.51609375)]), RelationRecord(items=frozenset({'nan', 'olive oil', 'chicken', 'spaghetti'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'chicken', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20155038759689922, lift=3.0603835169318647)]), RelationRecord(items=frozenset({'ground beef', 'chocolate', 'mineral water', 'eggs'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'chocolate', 'mineral water', 'eggs'}), items_add=frozenset({'ground beef'}), confidence=0.29702970297029707, lift=3.023093354111531)]), RelationRecord(items=frozenset({'frozen vegetables', 'chocolate', 'ground beef', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.34246575342465757, lift=3.4855300087358976), OrderedStatistic(items_base=frozenset({'ground beef', 'chocolate', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.30487804878048785, lift=3.1984478935698455)]), RelationRecord(items=frozenset({'frozen vegetables', 'chocolate', 'ground beef', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'ground beef'}), items_add=frozenset({'spaghetti'}), confidence=0.5348837209302326, lift=3.0721001460165964), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3898305084745763, lift=3.967596531978015), OrderedStatistic(items_base=frozenset({'ground beef', 'chocolate', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.33333333333333337, lift=3.4969696969696975)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'chocolate', 'mineral water'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.4109589041095891, lift=3.1714019956029094)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'chocolate', 'spaghetti'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.44067796610169485, lift=3.4007463207086555), OrderedStatistic(items_base=frozenset({'milk', 'chocolate', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3170731707317073, lift=3.3263858093126384)]), RelationRecord(items=frozenset({'frozen vegetables', 'chocolate', 'shrimp', 'mineral water'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'chocolate', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.32876712328767127, lift=4.600899611531385), OrderedStatistic(items_base=frozenset({'chocolate', 'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.4210526315789474, lift=4.417224880382776)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'shrimp'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate'}), items_add=frozenset({'shrimp'}), confidence=0.23255813953488375, lift=3.2545123221103784), OrderedStatistic(items_base=frozenset({'nan', 'chocolate', 'shrimp'}), items_add=frozenset({'frozen vegetables'}), confidence=0.29629629629629634, lift=3.1084175084175087)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'chocolate', 'herb & pepper'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'chocolate'}), items_add=frozenset({'ground beef'}), confidence=0.4411764705882354, lift=4.4901827759597746)]), RelationRecord(items=frozenset({'milk', 'chocolate', 'nan', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'chocolate', 'soup'}), items_add=frozenset({'milk'}), confidence=0.3947368421052632, lift=3.0462150747238472)]), RelationRecord(items=frozenset({'spaghetti', 'chocolate', 'olive oil', 'mineral water'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'chocolate', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.2436974789915966, lift=3.700353825740822)]), RelationRecord(items=frozenset({'spaghetti', 'chocolate', 'shrimp', 'mineral water'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'chocolate', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.21848739495798317, lift=3.0576006522011783)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'cooking oil', 'spaghetti'}), support=0.004799360085321957, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'cooking oil'}), items_add=frozenset({'spaghetti'}), confidence=0.5714285714285714, lift=3.2819951870487856), OrderedStatistic(items_base=frozenset({'nan', 'cooking oil', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3025210084033613, lift=3.0789824749438446)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'mineral water', 'eggs'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'mineral water', 'eggs'}), items_add=frozenset({'milk'}), confidence=0.411764705882353, lift=3.177620430888405)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'herb & pepper', 'eggs'}), support=0.0041327822956939075, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'eggs'}), items_add=frozenset({'herb & pepper'}), confidence=0.2066666666666667, lift=4.178454627133872), OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'eggs'}), items_add=frozenset({'ground beef'}), confidence=0.3297872340425532, lift=3.3564912381997174)]), RelationRecord(items=frozenset({'spaghetti', 'nan', 'red wine', 'eggs'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'red wine', 'eggs'}), items_add=frozenset({'spaghetti'}), confidence=0.5283018867924528, lift=3.0342974370828397)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'herb & pepper', 'french fries'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'french fries'}), items_add=frozenset({'herb & pepper'}), confidence=0.23076923076923078, lift=4.665768194070081), OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'french fries'}), items_add=frozenset({'ground beef'}), confidence=0.46153846153846156, lift=4.697421981004071)]), RelationRecord(items=frozenset({'spaghetti', 'milk', 'mineral water', 'frozen smoothie'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'mineral water', 'frozen smoothie'}), items_add=frozenset({'milk'}), confidence=0.4705882352941177, lift=3.631566206729606), OrderedStatistic(items_base=frozenset({'spaghetti', 'milk', 'mineral water'}), items_add=frozenset({'frozen smoothie'}), confidence=0.2033898305084746, lift=3.211846565566459)]), RelationRecord(items=frozenset({'frozen vegetables', 'green tea', 'nan', 'tomatoes'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'green tea', 'nan'}), items_add=frozenset({'tomatoes'}), confidence=0.2314814814814815, lift=3.38468341635983)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'ground beef', 'mineral water'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'ground beef', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.40579710144927533, lift=3.1315679608755294), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.3373493975903614, lift=3.4334570302921317), OrderedStatistic(items_base=frozenset({'ground beef', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3373493975903614, lift=3.539101861993428)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'ground beef', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'ground beef'}), items_add=frozenset({'spaghetti'}), confidence=0.5348837209302326, lift=3.0721001460165964), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3709677419354839, lift=3.7756160546242397), OrderedStatistic(items_base=frozenset({'ground beef', 'milk', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3150684931506849, lift=3.305354919053549)]), RelationRecord(items=frozenset({'frozen vegetables', 'ground beef', 'spaghetti', 'mineral water'}), support=0.004399413411545127, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.3666666666666667, lift=3.7318407960199007)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'ground beef', 'spaghetti'}), support=0.008665511265164644, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.31100478468899523, lift=3.165328208890303)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'olive oil', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.30120481927710846, lift=4.573557387444516), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'olive oil', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.5102040816326531, lift=3.937284790459394), OrderedStatistic(items_base=frozenset({'milk', 'olive oil', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.39062500000000006, lift=4.098011363636364)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'soup', 'mineral water'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'mineral water'}), items_add=frozenset({'soup'}), confidence=0.27710843373493976, lift=5.484407286136631), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'soup'}), items_add=frozenset({'mineral water'}), confidence=0.7666666666666666, lift=3.21631245339299), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'soup', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.6052631578947368, lift=4.670863114576565), OrderedStatistic(items_base=frozenset({'soup', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.35937500000000006, lift=3.7701704545454553)]), RelationRecord(items=frozenset({'frozen vegetables', 'milk', 'spaghetti', 'mineral water'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.28813559322033894, lift=3.0228043143297376)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'olive oil'}), support=0.004799360085321957, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk'}), items_add=frozenset({'olive oil'}), confidence=0.20338983050847456, lift=3.088314005352364), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'olive oil'}), items_add=frozenset({'milk'}), confidence=0.4235294117647058, lift=3.2684095860566447)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'soup'}), items_add=frozenset({'milk'}), confidence=0.5, lift=3.858539094650206)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'tomatoes'}), support=0.0041327822956939075, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'tomatoes'}), items_add=frozenset({'frozen vegetables'}), confidence=0.29523809523809524, lift=3.0973160173160172)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'shrimp', 'mineral water'}), support=0.007199040127982935, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3068181818181818, lift=3.218801652892562)]), RelationRecord(items=frozenset({'frozen vegetables', 'shrimp', 'spaghetti', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.2777777777777778, lift=3.8873341625207294), OrderedStatistic(items_base=frozenset({'spaghetti', 'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.39062500000000006, lift=4.098011363636364)]), RelationRecord(items=frozenset({'frozen vegetables', 'tomatoes', 'spaghetti', 'mineral water'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'spaghetti', 'mineral water'}), items_add=frozenset({'tomatoes'}), confidence=0.2555555555555556, lift=3.7366904916612524), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'tomatoes', 'mineral water'}), items_add=frozenset({'spaghetti'}), confidence=0.5227272727272727, lift=3.0022796881525826), OrderedStatistic(items_base=frozenset({'spaghetti', 'tomatoes', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.32857142857142857, lift=3.447012987012987)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'olive oil', 'spaghetti'}), support=0.005732568990801226, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20574162679425836, lift=3.1240241752707125)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'spaghetti', 'shrimp'}), support=0.005999200106652446, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti'}), items_add=frozenset({'shrimp'}), confidence=0.21531100478468898, lift=3.0131489680782684)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'tomatoes', 'shrimp'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'shrimp'}), items_add=frozenset({'tomatoes'}), confidence=0.24000000000000002, lift=3.5092397660818717), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'tomatoes'}), items_add=frozenset({'shrimp'}), confidence=0.2479338842975207, lift=3.4696866905143704), OrderedStatistic(items_base=frozenset({'nan', 'tomatoes', 'shrimp'}), items_add=frozenset({'frozen vegetables'}), confidence=0.35714285714285715, lift=3.7467532467532467)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'tomatoes', 'spaghetti'}), support=0.006665777896280496, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti'}), items_add=frozenset({'tomatoes'}), confidence=0.23923444976076558, lift=3.4980460188216425), OrderedStatistic(items_base=frozenset({'nan', 'tomatoes', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3184713375796179, lift=3.341053850607991)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'grated cheese', 'spaghetti'}), support=0.005332622317024397, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'grated cheese', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3225806451612903, lift=3.283144395325426)]), RelationRecord(items=frozenset({'green tea', 'nan', 'ground beef', 'tomatoes'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'green tea', 'nan', 'ground beef'}), items_add=frozenset({'tomatoes'}), confidence=0.2072072072072072, lift=3.0297490472929067)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'milk', 'herb & pepper'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'milk'}), items_add=frozenset({'ground beef'}), confidence=0.3913043478260869, lift=3.9825968969382335)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'herb & pepper', 'mineral water'}), support=0.006665777896280496, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.39062500000000006, lift=3.975682666214383)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'herb & pepper', 'spaghetti'}), support=0.006399146780429276, ordered_statistics=[OrderedStatistic(items_base=frozenset({'herb & pepper', 'nan', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3934426229508197, lift=4.004359721511667)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'milk', 'olive oil'}), support=0.004932675643247567, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'milk'}), items_add=frozenset({'olive oil'}), confidence=0.22424242424242427, lift=3.40494417862839)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'milk', 'soup'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'soup'}), items_add=frozenset({'milk'}), confidence=0.4109589041095891, lift=3.1714019956029094)]), RelationRecord(items=frozenset({'ground beef', 'olive oil', 'spaghetti', 'mineral water'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'olive oil', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.2987012987012987, lift=3.0401064335935435)]), RelationRecord(items=frozenset({'ground beef', 'tomatoes', 'spaghetti', 'mineral water'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'tomatoes', 'mineral water'}), items_add=frozenset({'spaghetti'}), confidence=0.5609756097560976, lift=3.221958689724723), OrderedStatistic(items_base=frozenset({'spaghetti', 'tomatoes', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.32857142857142857, lift=3.344117076952898)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'pepper', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'pepper', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.33783783783783783, lift=3.4384282518610876)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'spaghetti', 'shrimp'}), support=0.005999200106652446, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'shrimp'}), items_add=frozenset({'spaghetti'}), confidence=0.5232558139534884, lift=3.005315360233627)]), RelationRecord(items=frozenset({'ground beef', 'nan', 'tomato sauce', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'tomato sauce'}), items_add=frozenset({'spaghetti'}), confidence=0.5750000000000001, lift=3.3025076569678413), OrderedStatistic(items_base=frozenset({'nan', 'tomato sauce', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.4893617021276596, lift=4.980599901844742)]), RelationRecord(items=frozenset({'spaghetti', 'milk', 'olive oil', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'milk', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.211864406779661, lift=3.216993755575379)]), RelationRecord(items=frozenset({'spaghetti', 'milk', 'tomatoes', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'milk', 'mineral water'}), items_add=frozenset({'tomatoes'}), confidence=0.211864406779661, lift=3.0978458387022165)]), RelationRecord(items=frozenset({'nan', 'milk', 'olive oil', 'shrimp'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'olive oil', 'shrimp'}), items_add=frozenset({'milk'}), confidence=0.39999999999999997, lift=3.0868312757201646)]), RelationRecord(items=frozenset({'nan', 'milk', 'olive oil', 'soup'}), support=0.0035995200639914677, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'olive oil'}), items_add=frozenset({'soup'}), confidence=0.2109375, lift=4.174781497361478), OrderedStatistic(items_base=frozenset({'nan', 'milk', 'soup'}), items_add=frozenset({'olive oil'}), confidence=0.23684210526315788, lift=3.5962603878116344), OrderedStatistic(items_base=frozenset({'nan', 'olive oil', 'soup'}), items_add=frozenset({'milk'}), confidence=0.4029850746268656, lift=3.1098673300165833)]), RelationRecord(items=frozenset({'nan', 'milk', 'olive oil', 'spaghetti'}), support=0.007199040127982935, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20300751879699247, lift=3.0825089038385434)]), RelationRecord(items=frozenset({'nan', 'milk', 'tomatoes', 'soup'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'milk', 'tomatoes'}), items_add=frozenset({'soup'}), confidence=0.21904761904761905, lift=4.335293378565146), OrderedStatistic(items_base=frozenset({'nan', 'tomatoes', 'soup'}), items_add=frozenset({'milk'}), confidence=0.44230769230769235, lift=3.4133230452674903)]), RelationRecord(items=frozenset({'nan', 'milk', 'whole wheat pasta', 'spaghetti'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'whole wheat pasta', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.4545454545454546, lift=3.5077628133183696)]), RelationRecord(items=frozenset({'soup', 'nan', 'olive oil', 'mineral water'}), support=0.005199306759098787, ordered_statistics=[OrderedStatistic(items_base=frozenset({'soup', 'nan', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.22543352601156072, lift=3.4230301186492245)]), RelationRecord(items=frozenset({'nan', 'olive oil', 'whole wheat pasta', 'mineral water'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'whole wheat pasta', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.4027777777777778, lift=6.115862573099416)]), RelationRecord(items=frozenset({'nan', 'olive oil', 'pancakes', 'spaghetti'}), support=0.005065991201173177, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'pancakes', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.20105820105820105, lift=3.0529100529100526)]), RelationRecord(items=frozenset({'nan', 'olive oil', 'tomatoes', 'spaghetti'}), support=0.004399413411545127, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'olive oil', 'tomatoes'}), items_add=frozenset({'spaghetti'}), confidence=0.6111111111111112, lift=3.5099115194827295), OrderedStatistic(items_base=frozenset({'nan', 'tomatoes', 'spaghetti'}), items_add=frozenset({'olive oil'}), confidence=0.21019108280254778, lift=3.19158565202816)]), RelationRecord(items=frozenset({'nan', 'whole wheat rice', 'tomatoes', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'whole wheat rice', 'spaghetti'}), items_add=frozenset({'tomatoes'}), confidence=0.2169811320754717, lift=3.1726617382029496)]), RelationRecord(items=frozenset({'nan', 'chocolate', 'eggs', 'ground beef', 'mineral water'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'nan', 'chocolate', 'mineral water', 'eggs'}), items_add=frozenset({'ground beef'}), confidence=0.29702970297029707, lift=3.023093354111531)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'ground beef', 'mineral water'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.34246575342465757, lift=3.4855300087358976), OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.30487804878048785, lift=3.1984478935698455)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'ground beef', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'ground beef'}), items_add=frozenset({'spaghetti'}), confidence=0.5348837209302326, lift=3.0721001460165964), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3898305084745763, lift=3.967596531978015), OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'chocolate', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.33333333333333337, lift=3.4969696969696975)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'milk', 'mineral water'}), support=0.003999466737768298, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.4109589041095891, lift=3.1714019956029094)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'milk', 'spaghetti'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'spaghetti'}), items_add=frozenset({'milk'}), confidence=0.44067796610169485, lift=3.4007463207086555), OrderedStatistic(items_base=frozenset({'milk', 'chocolate', 'nan', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3170731707317073, lift=3.3263858093126384)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'chocolate', 'shrimp', 'mineral water'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.32876712328767127, lift=4.600899611531385), OrderedStatistic(items_base=frozenset({'nan', 'chocolate', 'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.4210526315789474, lift=4.417224880382776)]), RelationRecord(items=frozenset({'nan', 'chocolate', 'mineral water', 'spaghetti', 'olive oil'}), support=0.0038661511798426876, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.2436974789915966, lift=3.700353825740822)]), RelationRecord(items=frozenset({'nan', 'chocolate', 'mineral water', 'shrimp', 'spaghetti'}), support=0.0034662045060658577, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'chocolate', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.21848739495798317, lift=3.0576006522011783)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'eggs', 'mineral water'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'mineral water', 'eggs'}), items_add=frozenset({'milk'}), confidence=0.411764705882353, lift=3.177620430888405)]), RelationRecord(items=frozenset({'nan', 'mineral water', 'frozen smoothie', 'milk', 'spaghetti'}), support=0.003199573390214638, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'mineral water', 'frozen smoothie'}), items_add=frozenset({'milk'}), confidence=0.4705882352941177, lift=3.631566206729606), OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'frozen smoothie'}), confidence=0.2033898305084746, lift=3.211846565566459)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'ground beef', 'mineral water'}), support=0.0037328356219170776, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'ground beef', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.40579710144927533, lift=3.1315679608755294), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.3373493975903614, lift=3.4334570302921317), OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3373493975903614, lift=3.539101861993428)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'ground beef', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'milk', 'ground beef', 'nan'}), items_add=frozenset({'spaghetti'}), confidence=0.5348837209302326, lift=3.0721001460165964), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk', 'spaghetti'}), items_add=frozenset({'ground beef'}), confidence=0.3709677419354839, lift=3.7756160546242397), OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'milk', 'spaghetti'}), items_add=frozenset({'frozen vegetables'}), confidence=0.3150684931506849, lift=3.305354919053549)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'mineral water', 'ground beef', 'spaghetti'}), support=0.004399413411545127, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.3666666666666667, lift=3.7318407960199007)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'milk', 'mineral water', 'olive oil'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.30120481927710846, lift=4.573557387444516), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'olive oil', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.5102040816326531, lift=3.937284790459394), OrderedStatistic(items_base=frozenset({'nan', 'milk', 'olive oil', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.39062500000000006, lift=4.098011363636364)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'soup', 'milk', 'mineral water'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'soup'}), confidence=0.27710843373493976, lift=5.484407286136631), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'milk', 'soup'}), items_add=frozenset({'mineral water'}), confidence=0.7666666666666666, lift=3.21631245339299), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'soup', 'mineral water'}), items_add=frozenset({'milk'}), confidence=0.6052631578947368, lift=4.670863114576565), OrderedStatistic(items_base=frozenset({'soup', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.35937500000000006, lift=3.7701704545454553)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'mineral water', 'milk', 'spaghetti'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.28813559322033894, lift=3.0228043143297376)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'mineral water', 'shrimp', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti', 'mineral water'}), items_add=frozenset({'shrimp'}), confidence=0.2777777777777778, lift=3.8873341625207294), OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'shrimp', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.39062500000000006, lift=4.098011363636364)]), RelationRecord(items=frozenset({'frozen vegetables', 'nan', 'mineral water', 'tomatoes', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'spaghetti', 'mineral water'}), items_add=frozenset({'tomatoes'}), confidence=0.2555555555555556, lift=3.7366904916612524), OrderedStatistic(items_base=frozenset({'frozen vegetables', 'nan', 'tomatoes', 'mineral water'}), items_add=frozenset({'spaghetti'}), confidence=0.5227272727272727, lift=3.0022796881525826), OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'tomatoes', 'mineral water'}), items_add=frozenset({'frozen vegetables'}), confidence=0.32857142857142857, lift=3.447012987012987)]), RelationRecord(items=frozenset({'nan', 'mineral water', 'ground beef', 'spaghetti', 'olive oil'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'olive oil', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.2987012987012987, lift=3.0401064335935435)]), RelationRecord(items=frozenset({'nan', 'mineral water', 'ground beef', 'tomatoes', 'spaghetti'}), support=0.0030662578322890282, ordered_statistics=[OrderedStatistic(items_base=frozenset({'ground beef', 'nan', 'tomatoes', 'mineral water'}), items_add=frozenset({'spaghetti'}), confidence=0.5609756097560976, lift=3.221958689724723), OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'tomatoes', 'mineral water'}), items_add=frozenset({'ground beef'}), confidence=0.32857142857142857, lift=3.344117076952898)]), RelationRecord(items=frozenset({'nan', 'mineral water', 'milk', 'spaghetti', 'olive oil'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'olive oil'}), confidence=0.211864406779661, lift=3.216993755575379)]), RelationRecord(items=frozenset({'nan', 'mineral water', 'milk', 'tomatoes', 'spaghetti'}), support=0.003332888948140248, ordered_statistics=[OrderedStatistic(items_base=frozenset({'spaghetti', 'nan', 'milk', 'mineral water'}), items_add=frozenset({'tomatoes'}), confidence=0.211864406779661, lift=3.0978458387022165)])]

apyori.py中apriori(transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2)方法:

  • 第一个传入参数transactions是交易清单中每行交易记录中的食品单词列表;例如部分记录如下:
0000 = {list} <class 'list'>: ['shrimp', 'almonds', 'avocado', 'vegetables mix', 'green grapes', 'whole weat flour', 'yams', 'cottage cheese', 'energy drink', 'tomato juice', 'low fat yogurt', 'green tea', 'honey', 'salad', 'mineral water', 'salmon', 'antioxydant juice', 'frozen smoothie', 'spinach', 'olive oil']
0001 = {list} <class 'list'>: ['burgers', 'meatballs', 'eggs', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan']
.......

  • 第二个参数是最小支持度min_support = 0.003,支持度是一个项集或者规则在所有事物中出现的频率。这里是每行中的单词集在所有记录中出现的次数与总记录行数的比值;例如:almonds食品在Market_Basket_Optimisation文件中出现了153次,而Market_Basket_Optimisation文件的总记录数为7501行,因此almonds的支持度为153 / 7501 =0.02039728,和代码中计算结果是一样的。如果单词支持度小于最小支持度min_support = 0.003,单词出现的次数小于7501*0.003= 22.503次, 为减少计算量,这个单词可以过滤清洗掉。 

 

  • 第三个参数是置信度min_confidence = 0.2,例如 light cream−−>chicken的关联规则,这条规则的置信度为“ 支持度({'light cream', 'chicken'})  /  支持度({light cream})”。  查看apyori.py的运行结果, {'light cream', 'chicken'}的支持度是 0.004532728969470737
items=frozenset({'light cream', 'chicken'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'light cream'}), items_add=frozenset({'chicken'}), confidence=0.29059829059829057, lift=4.84395061728395)]) 

{light cream} 的支持度为0.01559792(light cream在Market_Basket_Optimisation文件出现的次数为117次,Market_Basket_Optimisation总行数为7501次,light cream的支持度=117/7501 =0.01559792), 所以关联规则 {light cream−−>chicken}的可信度为0.004532728969470737/ 0.01559792 =  0.290598291,和代码中的计算结果是一样的 , 对于所有包含 "light cream"的记录中,”light cream−−>chicken“关联规则对light cream的 29% 记录都适用。

  • 第四个参数是提升度 min_lift = 3。关于lift提升度:例如 light cream−−>chicken的关联规则,lift=4.84395061728395,表明客户购买light cream之后再购买chicken商品的可能性 是 没有购买light cream 但是购买了chicken的可能性 的4.84395061728395倍;这里也设置一个阀值, min_lift = 3。
 items=frozenset({'light cream', 'chicken'}), support=0.004532728969470737, ordered_statistics=[OrderedStatistic(items_base=frozenset({'light cream'}), items_add=frozenset({'chicken'}), confidence=0.29059829059829057, lift=4.84395061728395)]) 
  • 第五个参数是min_length = 2,表示规则中至少包含两种食品,防止出现类似“{}=>chicken”的规则。

   这里从Apriori算法的应用方面自己做了一些测试,具体的算法原理可以参考家林大神的Apriori源代码及视频课程讲解。

猜你喜欢

转载自blog.csdn.net/duan_zhihua/article/details/81406900
今日推荐