PM4py 二开记录(6) :get_events_distribution log中挖掘足迹模型

本文介绍了如何使用PM4Py库对事件日志中的活动进行关系分析,包括直接跟随关系、并行行为的发现,以及通过诱导式挖掘发现过程模型。之后,文章展示了足迹发现和一致性检查的方法,以评估日志与模型的符合度。
摘要由CSDN通过智能技术生成

推断日志/模型的任何两个活动之间的关系。

  • 直接跟随关系(>):活动B紧随A。A在前,B在后 (dfg)
  • 直接被跟随关系(<):活动A紧随B。B在前,A在后 (sequence)
  • 并行行为(||):可能是A后面跟着B,B后面跟着A (parallel)

import os
from pm4py.objects.log.importer.xes import importer
from pm4py.algo.filtering.log.variants import variants_filter
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.objects.conversion.process_tree import converter
from pm4py.algo.discovery.footprints import algorithm as footprints_discovery
from pm4py.algo.conformance.footprints import algorithm as footprints_conformance
from pm4py.visualization.footprints import visualizer as fp_visualizer
from examples import examples_conf

if __name__ == "__main__":
    # import a log
    log = importer.apply(os.path.join("..", "tests", "input_data", "receipt.xes"))
    # found a filtered version of the log that is used to discover a process model
    filtered_log = variants_filter.filter_log_variants_percentage(log, 0.2)
    # discover a process tree using inductive miner
    tree = inductive_miner.apply(filtered_log)
    print(tree)
    # apply the conversion of a process tree into a Petri net
    net, im, fm = converter.apply(tree)
    # Footprints discovery: discover a list of footprints
    # for all the cases of the log
    fp_log = footprints_discovery.apply(log)

    # discover the footpritns from the Petri net
    fp_net = footprints_discovery.apply(net, im)

    # finds the footprints for the entire log (not case-by-case, but taking
    # the relations that appear inside the entire log)
    fp_log_entire = footprints_discovery.apply(log, variant=footprints_discovery.Variants.ENTIRE_EVENT_LOG)
    # visualize the footprint table
    gviz = fp_visualizer.apply(fp_log_entire, fp_net, parameters={"format": examples_conf.TARGET_IMG_FORMAT})
    fp_visualizer.view(gviz)


    # discover the footpritns from the process tree
    fp_tree = footprints_discovery.apply(tree)
    print(len(fp_tree["sequence"]), len(fp_tree["parallel"]), len(fp_net["sequence"]), len(fp_net["parallel"]))
    print(fp_tree["sequence"] == fp_net["sequence"] and fp_tree["parallel"] == fp_net["parallel"])
    # apply the footprints conformance checking
    conf = footprints_conformance.apply(fp_log, fp_net)
    i = 0
    for trace_an in conf:
        if trace_an:
            # print the first anomalous trace (containing deviations
            # that are contained in the trace but not allowed by the model
            print(log[i].attributes['concept:name'])
            print(trace_an) 
            i = i + 1

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值