def get_case_arrival_average(log: Union[EventLog, pd.DataFrame]) -> float:
    """
    Gets the average difference between the start times of two consecutive cases

    Parameters
    ---------------
    log
        Log object

    Returns
    ---------------
    case_arrival_average
        Average difference between the start times of two consecutive cases
    """
    if check_is_dataframe(log):
        check_dataframe_columns(log)
        from pm4py.statistics.traces.pandas import case_arrival
        return case_arrival.get_case_arrival_avg(log)
    else:
        from pm4py.statistics.traces.log import case_arrival
        return case_arrival.get_case_arrival_avg(log)
parameters[PARAMETER_CONSTANT_ATTRIBUTE_KEY] = parameters[
    PARAMETER_CONSTANT_ACTIVITY_KEY]
CASEID_GLUE = parameters[PARAMETER_CONSTANT_CASEID_KEY]
ACTIVITY_KEY = parameters[PARAMETER_CONSTANT_ACTIVITY_KEY]
TIMEST_KEY = parameters[PARAMETER_CONSTANT_TIMESTAMP_KEY]

df = pandas_df_imp.import_dataframe_from_path(log_name)
# obtain a simple, sound workflow net, containing only visibile unique transitions,
# applying the Alpha Miner to some of the top variants (methods by Ale)
net, initial_marking, final_marking = model_factory.apply(df,
                                                          classic_output=True)
# visualize the output Petri net
gviz = pn_vis_factory.apply(net, initial_marking, final_marking)
pn_vis_factory.view(gviz)
# gets the average time between cases starts
avg_time_starts = get_case_arrival_avg(df)
print("avg_time_starts=", avg_time_starts)
# gets the aggregated statistics calculated on the DFG graph and the Petri net
activities_count = attributes_filter.get_attribute_values(
    df, attribute_key=ACTIVITY_KEY)
[dfg_frequency,
 dfg_performance] = df_statistics.get_dfg_graph(df,
                                                measure="both",
                                                perf_aggregation_key="median",
                                                case_id_glue=CASEID_GLUE,
                                                activity_key=ACTIVITY_KEY,
                                                timestamp_key=TIMEST_KEY)
spaths = get_shortest_paths(net)
aggregated_statistics = get_decorations_from_dfg_spaths_acticount(
    net, dfg_performance, spaths, activities_count, variant="performance")
# gets the stochastic distribution associated to the Petri net and the dataframe
Exemple #3
0
 def test_case_arrival(self):
     from pm4py.statistics.traces.pandas import case_arrival
     df = self.get_dataframe()
     case_arrival.get_case_arrival_avg(df)