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?

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

3 Comments

Does not work, same error.
@vojta stackoverflow.com/a/31995624/1021819 does not work for you?
@MrFuppes Edited to remove lambda (no longer seems elegant / worth it..)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.