Пример #1
0
def apply(log, parameters=None):
    """
    Apply the IMDF algorithm to a log obtaining a Petri net along with an initial and final marking

    Parameters
    -----------
    log
        Log
    parameters
        Parameters of the algorithm, including:
            pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY -> attribute of the log to use as activity name
            (default concept:name)

    Returns
    -----------
    net
        Petri net
    initial_marking
        Initial marking
    final_marking
        Final marking
    """
    if parameters is None:
        parameters = {}
    if pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY not in parameters:
        parameters[pmutil.constants.
                   PARAMETER_CONSTANT_ACTIVITY_KEY] = xes_util.DEFAULT_NAME_KEY
    if pmutil.constants.PARAMETER_CONSTANT_TIMESTAMP_KEY not in parameters:
        parameters[
            pmutil.constants.
            PARAMETER_CONSTANT_TIMESTAMP_KEY] = xes_util.DEFAULT_TIMESTAMP_KEY
    if pmutil.constants.PARAMETER_CONSTANT_CASEID_KEY not in parameters:
        parameters[
            pmutil.constants.
            PARAMETER_CONSTANT_CASEID_KEY] = pmutil.constants.CASE_ATTRIBUTE_GLUE
    if type(log) is pd.DataFrame:
        return apply_variants(variants_get.get_variants_set(
            log, parameters=parameters),
                              parameters=parameters)
    else:
        log = log_conversion.apply(log, parameters,
                                   log_conversion.TO_EVENT_LOG)
        tree = apply_tree(log, parameters=parameters)
        net, initial_marking, final_marking = tree_to_petri.apply(tree)
        return net, initial_marking, final_marking
Пример #2
0
def apply_tree(log, parameters=None):
    """
    Apply the IMDF algorithm to a log obtaining a process tree

    Parameters
    ----------
    log
        Log
    parameters
        Parameters of the algorithm, including:
            pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY -> attribute of the log to use as activity name
            (default concept:name)

    Returns
    ----------
    tree
        Process tree
    """
    if parameters is None:
        parameters = {}
    if pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY not in parameters:
        parameters[pmutil.constants.
                   PARAMETER_CONSTANT_ACTIVITY_KEY] = xes_util.DEFAULT_NAME_KEY
    if pmutil.constants.PARAMETER_CONSTANT_TIMESTAMP_KEY not in parameters:
        parameters[
            pmutil.constants.
            PARAMETER_CONSTANT_TIMESTAMP_KEY] = xes_util.DEFAULT_TIMESTAMP_KEY
    if pmutil.constants.PARAMETER_CONSTANT_CASEID_KEY not in parameters:
        parameters[
            pmutil.constants.
            PARAMETER_CONSTANT_CASEID_KEY] = pmutil.constants.CASE_ATTRIBUTE_GLUE
    if type(log) is pd.DataFrame:
        return apply_tree_variants(variants_get.get_variants_set(
            log, parameters=parameters),
                                   parameters=parameters)
    else:
        activity_key = parameters[
            pmutil.constants.PARAMETER_CONSTANT_ACTIVITY_KEY]
        traces = Counter([
            tuple(y[activity_key] for y in x if activity_key in y) for x in log
        ])
        return apply_internal(traces)
Пример #3
0
 def test_df_tree_variants_dfg_based(self):
     df = pd.read_csv(os.path.join("input_data", "running-example.csv"))
     df = dataframe_utils.convert_timestamp_columns_in_df(df)
     tree = inductive_miner.apply_tree_variants(
         pd_variants.get_variants_set(df),
         variant=inductive_miner.DFG_BASED)
 def test_df_tree_variants_dfg_based_old(self):
     df = csv_importer.import_dataframe_from_path(
         os.path.join("input_data", "running-example.csv"))
     tree = inductive_miner.apply_tree_variants(
         pd_variants.get_variants_set(df),
         variant=inductive_miner.DFG_BASED_OLD_VERSION)
 def test_df_variants_dfg_based(self):
     df = csv_importer.import_dataframe_from_path(
         os.path.join("input_data", "running-example.csv"))
     net, im, fm = inductive_miner.apply_variants(
         pd_variants.get_variants_set(df),
         variant=inductive_miner.DFG_BASED)