本文整理汇总了Python中stats.Stats.record_post_rules方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.record_post_rules方法的具体用法?Python Stats.record_post_rules怎么用?Python Stats.record_post_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.Stats
的用法示例。
在下文中一共展示了Stats.record_post_rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import record_post_rules [as 别名]
def process(infile, algorithm_name, support, confidence, m, random, partial):
stats = Stats()
transactions = TransactionsList(infile)
stats.record_post_large_sets()
stats.record_post_rules()
last_total_time = stats.real_time
last_user_time = stats.user_time
stats = Stats()
if algorithm_name == 'apriori':
algorithm = Apriori(transactions, support)
else:
algorithm = Dic(transactions, support, m, random, partial)
large_sets, counter = algorithm.get_large_sets_and_counter()
stats.record_post_large_sets()
rules = RulesGenerator.generate_rules(large_sets, confidence, counter, transactions)
stats.record_post_rules()
large_len = len(large_sets)
total_time = stats.real_time - last_total_time
user_time = stats.user_time - last_user_time
large_sets_time = stats.set_gen_time - last_total_time
last_total_time = stats.real_time
last_user_time = stats.user_time
memory = stats.memory_use
rules_no = len(rules)
print "{infile}\t{algorithm_name}\t{support}\t{confidence}\t{m}\t{rules_no}\t{large_len}\t{memory}\t{total_time}\t{user_time}\t{large_sets_time}\t{partial}\t{random}".format(**locals())
示例2: main
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import record_post_rules [as 别名]
def main(args):
stats = Stats()
transactions = TransactionsList(args.infile)
if args.algorithm == 'apriori':
algorithm = Apriori(transactions, args.minsup)
else:
algorithm = Dic(transactions, args.minsup, args.m)
large_sets, counter = algorithm.get_large_sets_and_counter()
stats.record_post_large_sets()
rules = RulesGenerator.generate_rules(large_sets, args.minconf, counter, transactions)
stats.record_post_rules()
writer = Writer(args.outfile)
writer.add_args(args)
writer.add_stats(stats)
writer.add_rules(rules)
writer.write()