I need an algorithm that takes the frequencies of unique combinations of products in a market-basket training set and uses these frequencies to output a single product recommendation for each incomplete shopping cart in a test set. For example, lets say that P01, P02 has a frequency of 10 and P01,P03 has a frequency of 8 in the training set. The test set has a shopping cart with P01 in it. My output for this item should be P02. This must be done in Python using only the packages available in the Anaconda distribution. Suggestions? 
Frequency-based recommendations
python;market basket analysis