0

I have a following function:

def calculate_frequent_itemset(fractional_data, support):
    """Function that calculated the frequent dataset parallely"""
    return apriori(fractional_data, min_support=support, use_colnames=True) 

I would like to call it in a map function using:

frequent_itemsets=p.map(calculate_frequent_itemset,(dataNew1,dataNew2,dataNew3,dataNew4,dataNew5), 200)

In other words I want to set 200 as support argument. But I got an error TypeError: calculate_frequent_itemset() missing 1 required positional argument: 'support'. How can I fix it please?

vojta
  • 122
  • 1
  • 15

1 Answers1

0

You could use a wrapper function (or a lambda):

support=200
def my_calculate_frequent_itemset(fractional_data):
    return calculate_frequent_itemset(fractional_data, support)

frequent_itemsets=p.map(my_calculate_frequent_itemset,(dataNew1,dataNew2,dataNew3,dataNew4,dataNew5))

It's pretty horrible.

I rediscovered this - rather perhaps see https://stackoverflow.com/a/31995624/1021819 which gives the same answer

jtlz2
  • 7,700
  • 9
  • 64
  • 114