TypeError: apriori() 得到一个意外的关键字参数'mini_support'


def perform_rule_calculation(transact_items_matrix, rule_type="fpgrowth", min_support=0.001):

start_time = 0
total_execution = 0

if(not rule_type=="fpgrowth"):
start_time = time.time()
rule_items = apriori(transact_items_matrix, 
mini_support=min_support, 
use_colnames=True, low_memory=True)
total_execution = time.time() - start_time
print("Computed Apriori!")

n_range = range(1, 10, 1)
list_time_ap = []
list_time_fp = []
for n in n_range:
time_ap = 0
time_fp = 0
min_sup = float(n/100)
time_ap = perform_rule_calculation(trans_encoder_matrix, rule_type="fpgrowth", min_support=min_sup)
time_fp = perform_rule_calculation(trans_encoder_matrix, rule_type="aprior", min_support=min_sup)
list_time_ap.append(time_ap)
list_time_fp.append(time_fp)

这是关于apriori vs FP增长算法的教程,这里的问题是在apriori中计算最小支持,我得到了这个错误。我该如何解决这个问题?

这只是一个拼写错误。您在生成规则时键入了mini而不是min。我已将其更正为低于

def perform_rule_calculation(transact_items_matrix, rule_type="fpgrowth", min_support=0.001):

start_time = 0
total_execution = 0

if(not rule_type=="fpgrowth"):
start_time = time.time()
rule_items = apriori(transact_items_matrix, 
min_support=min_support, 
use_colnames=True, low_memory=True)
total_execution = time.time() - start_time
print("Computed Apriori!")

n_range = range(1, 10, 1)
list_time_ap = []
list_time_fp = []
for n in n_range:
time_ap = 0
time_fp = 0
min_sup = float(n/100)
time_ap = perform_rule_calculation(trans_encoder_matrix, rule_type="fpgrowth", min_support=min_sup)
time_fp = perform_rule_calculation(trans_encoder_matrix, rule_type="aprior", min_support=min_sup)
list_time_ap.append(time_ap)
list_time_fp.append(time_fp)

相关内容

  • 没有找到相关文章

最新更新