PM4py 二开记录(7) :discover_dfg

Discovers a Directly-Follows Graph (DFG) from a log.

A Directly-Follows Graph (DFG) is the simplest representation of the process models. In a directly-follows graph, each node represents an activity and the arcs describe the relationship between various activities. Typically in a process model, the directly-follows graph has a source and sink representing the start and end activities.

在一个DFG图中,每个节点表示一个活动,其中的边表示活动之间的直接跟随关系。

搭配特殊的 filter 可以调整输出结果:(例子中 展示了 1、2 两种)

1. Filters a DFG (complete, and so connected) on the specified percentage of activities

2. Filters a DFG (complete, and so connected) on the specified percentage of paths

3. Filters a DFG (complete, and so connected) on the specified dependency threshold (Heuristics Miner dependency)

4. Filters the DFG, making "target_activity" the only possible end activity of the graph

5. Filters the DFG, making "source_activity" the only possible source activity of the graph

6. Filters the DFG keeping only nodes that can reach / are reachable from activity

7. Clean Directly-Follows graph based on noise threshold

    log = pm4py.read_xes("../tests/input_data/receipt.xes")
    dfg, sa, ea = pm4py.discover_dfg(log)
    act_count = pm4py.get_event_attribute_values(log, "concept:name")
    # keep the specified amount of activities
    dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_activities_percentage(dfg, sa, ea, act_count, 0.8)
    # keep the specified amount of paths
    dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_paths_percentage(dfg, sa, ea, act_count, 0.8)
    # view the DFG
    gviz = dfg_visualizer.apply(dfg, activities_count=act_count, parameters={dfg_visualizer.Variants.FREQUENCY.value.Parameters.START_ACTIVITIES: sa,
                                                                             dfg_visualizer.Variants.FREQUENCY.value.Parameters.END_ACTIVITIES: ea,
                                                                             dfg_visualizer.Variants.FREQUENCY.value.Parameters.FORMAT: examples_conf.TARGET_IMG_FORMAT})
    dfg_visualizer.view(gviz)


if __name__ == "__main__":
    # execute_script()
    log = pm4py.read_xes("../tests/input_data/receipt.xes")
    dfg, sa, ea = pm4py.discover_dfg(log)
    act_count = pm4py.get_event_attribute_values(log, "concept:name")
    # keep the specified amount of activities
    dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_activities_percentage(dfg, sa, ea, act_count, 0.8)
    # keep the specified amount of paths
    dfg, sa, ea, act_count = dfg_filtering.filter_dfg_on_paths_percentage(dfg, sa, ea, act_count, 0.8)
    # view the DFG
    gviz = dfg_visualizer.apply(dfg, activities_count=act_count, parameters={dfg_visualizer.Variants.FREQUENCY.value.Parameters.START_ACTIVITIES: sa,
                                                                             dfg_visualizer.Variants.FREQUENCY.value.Parameters.END_ACTIVITIES: ea,
                                                                             dfg_visualizer.Variants.FREQUENCY.value.Parameters.FORMAT: examples_conf.TARGET_IMG_FORMAT})
    dfg_visualizer.view(gviz)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值