Calculates the cycle time of the event log. 可以用下面两个方法:
log 需要有两个时间戳(开始和结束时间), 累计每笔log 的开始与结束时间差(秒), 再除以总比数就是cycle_time 了, 但是这个方法只计算总时间差。 比较适用于计算某个特定 event 的平均处理时间。
1. get_cycle_time
pm4py.get_cycle_time(event_log, activity_key='concept:name', case_id_key='case:concept:name', timestamp_key='time:timestamp',start_timestamp_key='start_timestamp')
这只API 本身不支持start_timestamp_key 参数, 计算不出值。 原函数修改就可以用了:def get_cycle_time(log: Union[EventLog, pd.DataFrame], activity_key: str = "concept:name", timestamp_key: str = "time:timestamp", start_timestamp_key: str = "start_timestamp", case_id_key: str = "case:concept:name") -> float:
2. cycle_time_get
from pm4py.statistics.traces.cycle_time.log import get as cycle_time_get cycle_time_get.apply(event_log, parameters={cycle_time_get.Parameters.START_TIMESTAMP_KEY: "start_timestamp",
cycle_time_get.Parameters.TIMESTAMP_KEY: "time:timestamp"})
event_log = pm4py.read_xes('inPut\\interval_event_log.xes', case_id='case:concept:name', activity_key='concept:name', timestamp_key='time:timestamp', start_timestamp_key='start_timestamp', timest_format='%Y-%m-%d %H:%M:%S')
start_activities = pm4py.get_start_activities(event_log)
end_activities = pm4py.get_end_activities(event_log)
print("Start activities: {}\nEnd activities: {}".format(start_activities, end_activities))
cycle_time1= cycle_time_get.apply(event_log, parameters={cycle_time_get.Parameters.START_TIMESTAMP_KEY: "start_timestamp",
cycle_time_get.Parameters.TIMESTAMP_KEY: "time:timestamp"})
print("cycle_time1", cycle_time1)
from pm4py.statistics.traces.cycle_time.log import get as cycle_time_get
cycle_time2 = pm4py.get_cycle_time(event_log, activity_key='concept:name', case_id_key='case:concept:name',
timestamp_key='time:timestamp',start_timestamp_key='start_timestamp')
print("cycle_time2", cycle_time2)
parsing log, completed traces :: 0%| | 0/1 [00:00<?, ?it/s]
Start activities: {'place order': 1}
End activities: {'confirm payment': 1}
cycle_time1 4913.0
cycle_time2 4913.0