human
Can you provide a Python program to find products which are frequently browsed together given the following:
3.3.1 OPTIONAL 
Using 2 reducers:  Report your findings such as number of unique products.
largest basket.
report the top 50 most frequently purchased items,  their frequency,  and their relative frequency (break ties by sorting the products alphabetical order) etc. using Hadoop Map-Reduce. 
HW3.4. (Computationally prohibitive but then again Hadoop can handle this) Pairs
Suppose we want to recommend new products to the customer based on the products they
have already browsed on the online website. Write a map-reduce program 
to find products which are frequently browsed together. Fix the support count (cooccurence count) to s = 100 
(i.e. product pairs need to occur together at least 100 times to be considered frequent) 
and find pairs of items (sometimes referred to itemsets of size 2 in association rule mining) that have a support count of 100 or more.
List the top 50 product pairs with corresponding support count (aka frequency), and relative frequency or support (number of records where they coccur, the number of records where they coccur/the number of baskets in the dataset)  in decreasing order of support  for frequent (100>count) itemsets of size 2. 
Use the Pairs pattern (lecture 3)  to  extract these frequent itemsets of size 2. Free free to use combiners if they bring value. Instrument your code with counters for count the number of times your mapper, combiner and reducers are called.  
Please output records of the following form for the top 50 pairs (itemsets of size 2): 
  item1, item2, support count, support

Fix the ordering of the pairs lexicographically (left to right), 
and break ties in support (between pairs, if any exist) 
by taking the first ones in lexicographically increasing order. 
Report  the compute time for the Pairs job. Describe the computational setup used (E.g., single computer.
dual core.
linux, number of mappers, number of reducers)
Instrument your mapper, combiner, and reducer to count how many times each is called using Counters and report these counts.
assistant
#Here is Python program to find products which are frequently browsed together.
%%writefile PairsRecommender.py

from mrjob.job import MRJob
import heapq
import sys

def all_itemsets_of_size_two(array, key=None, return_type="string", concat_val=" "):
    """
    Generator that yields all valid itemsets of size two
    where each combo is returned in an order sorted by key.
    
    key = None defaults to standard sorting.
    
    return_type: can be "string" or "tuple". If "string", 
    concatenates values with concat_val and returns string.
    If tuple, returns a tuple with two elements.
    """
    array = sorted(array, key=key)
    for index, item in enumerate(array):
        for other_item in array[index:]:
            if item != other_item:
                if return_type == "string":
                    yield "%s%s%s" % (str(item), concat_val, str(other_item))
                else:
                    yield (item, other_item) 

class TopList(list):
    def __init__(self, max_size):
        """
        Just like a list, except the append method adds the new value to the 
        list only if it is larger than the smallest value (or if the size of 
        the list is less than max_size). If each element of the list is an int
        or float, uses that value for comparison. If the first element is a 
        list or tuple, uses the first element of the list or tuple for the 
        comparison.
        """
        self.max_size = max_size
        
    def _get_key(self, x):
        return x[0] if isinstance(x, (list, tuple)) else x
        
    def append(self, val):
        key=lambda x: x[0] if isinstance(x, (list, tuple)) else x
        if len(self) < self.max_size:
            heapq.heappush(self, val)
        elif self._get_key(self[0]) < self._get_key(val):
            heapq.heapreplace(self, val)
            
    def final_sort(self):
        return sorted(self, key=self._get_key, reverse=True)
    
                    
class PairsRecommender(MRJob):
    def mapper_init(self):
        self.total_baskets = 0
    
    def mapper(self, _, lines):
        self.total_baskets +=...