def apply(dataframe, parameters=None): """ Gets the Petri net through Inductive Miner, decorated by performance metric Parameters ------------ dataframe Dataframe parameters Parameters of the algorithm Returns ------------ base64 Base64 of an SVG representing the model model Text representation of the model format Format of the model """ if parameters is None: parameters = {} decreasingFactor = parameters[ "decreasingFactor"] if "decreasingFactor" in parameters else constants.DEFAULT_DEC_FACTOR activity_key = parameters[ pm4_constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if pm4_constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY timestamp_key = parameters[ pm4_constants. PARAMETER_CONSTANT_TIMESTAMP_KEY] if pm4_constants.PARAMETER_CONSTANT_TIMESTAMP_KEY in parameters else xes.DEFAULT_TIMESTAMP_KEY case_id_glue = parameters[ pm4_constants. PARAMETER_CONSTANT_CASEID_KEY] if pm4_constants.PARAMETER_CONSTANT_CASEID_KEY in parameters else CASE_CONCEPT_NAME parameters[pm4_constants.RETURN_EA_COUNT_DICT_AUTOFILTER] = True dataframe = attributes_filter.filter_df_keeping_spno_activities( dataframe, activity_key=activity_key, max_no_activities=constants.MAX_NO_ACTIVITIES) dataframe, end_activities = auto_filter.apply_auto_filter( dataframe, parameters=parameters) end_activities = list(end_activities.keys()) activities_count = attributes_filter.get_attribute_values( dataframe, activity_key, parameters=parameters) activities = list(activities_count.keys()) start_activities = list( start_activities_filter.get_start_activities( dataframe, parameters=parameters).keys()) [dfg, dfg_perf ] = df_statistics.get_dfg_graph(dataframe, activity_key=activity_key, timestamp_key=timestamp_key, case_id_glue=case_id_glue, sort_caseid_required=False, sort_timestamp_along_case_id=False, measure="both") dfg = clean_dfg_based_on_noise_thresh( dfg, activities, decreasingFactor * constants.DEFAULT_DFG_CLEAN_MULTIPLIER, parameters=parameters) dfg_perf = {x: y for x, y in dfg_perf.items() if x in dfg} net, im, fm = inductive_miner.apply_dfg(dfg, parameters, activities=activities, start_activities=start_activities, end_activities=end_activities) spaths = get_shortest_paths(net) bpmn_graph, el_corr, inv_el_corr, el_corr_keys_map = petri_to_bpmn.apply( net, im, fm) aggregated_statistics = get_decorations_from_dfg_spaths_acticount( net, dfg_perf, spaths, activities_count, variant="performance") bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn( aggregated_statistics, inv_el_corr) #bpmn_graph = bpmn_embedding.embed_info_into_bpmn(bpmn_graph, bpmn_aggreg_statistics, "performance") bpmn_graph = bpmn_diagram_layouter.apply(bpmn_graph) bpmn_string = bpmn_exporter.get_string_from_bpmn(bpmn_graph) gviz = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "svg"}) gviz2 = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "dot"}) gviz_base64 = get_base64_from_file(gviz2.name) ret_graph = get_graph.get_graph_from_petri(net, im, fm) return get_base64_from_file(gviz.name), export_petri_as_string( net, im, fm ), ".pnml", "parquet", activities, start_activities, end_activities, gviz_base64, ret_graph, "indbpmn", "perf", bpmn_string, ".bpmn", activity_key
def apply(log, parameters=None): """ Gets the Petri net through Inductive Miner, decorated by frequency metric Parameters ------------ log Log parameters Parameters of the algorithm Returns ------------ base64 Base64 of an SVG representing the model model Text representation of the model format Format of the model """ if parameters is None: parameters = {} decreasingFactor = parameters[ "decreasingFactor"] if "decreasingFactor" in parameters else constants.DEFAULT_DEC_FACTOR activity_key = parameters[ pm4_constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if pm4_constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY # reduce the depth of the search done by token-based replay token_replay.MAX_REC_DEPTH = 1 token_replay.MAX_IT_FINAL1 = 1 token_replay.MAX_IT_FINAL2 = 1 token_replay.MAX_REC_DEPTH_HIDTRANSENABL = 1 log = attributes_filter.filter_log_on_max_no_activities( log, max_no_activities=constants.MAX_NO_ACTIVITIES, parameters=parameters) filtered_log = auto_filter.apply_auto_filter(log, parameters=parameters) activities_count = attributes_filter.get_attribute_values( filtered_log, activity_key) activities = list(activities_count.keys()) start_activities = list( start_activities_filter.get_start_activities( filtered_log, parameters=parameters).keys()) end_activities = list( end_activities_filter.get_end_activities(filtered_log, parameters=parameters).keys()) dfg = dfg_factory.apply(filtered_log, parameters=parameters) dfg = clean_dfg_based_on_noise_thresh( dfg, activities, decreasingFactor * constants.DEFAULT_DFG_CLEAN_MULTIPLIER, parameters=parameters) net, im, fm = inductive_miner.apply_dfg(dfg, parameters=parameters, activities=activities, start_activities=start_activities, end_activities=end_activities) parameters["format"] = "svg" gviz = pn_vis_factory.apply(net, im, fm, log=filtered_log, variant="frequency", parameters=parameters) svg = get_base64_from_gviz(gviz) gviz_base64 = base64.b64encode(str(gviz).encode('utf-8')) ret_graph = get_graph.get_graph_from_petri(net, im, fm) return svg, export_petri_as_string( net, im, fm ), ".pnml", "xes", activities, start_activities, end_activities, gviz_base64, ret_graph, "inductive", "freq", None, "", activity_key
def apply(dataframe, parameters=None): """ Gets the Petri net through Inductive Miner, decorated by frequency metric Parameters ------------ dataframe Dataframe parameters Parameters of the algorithm Returns ------------ base64 Base64 of an SVG representing the model model Text representation of the model format Format of the model """ if parameters is None: parameters = {} decreasingFactor = parameters[ "decreasingFactor"] if "decreasingFactor" in parameters else constants.DEFAULT_DEC_FACTOR activity_key = parameters[ pm4_constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if pm4_constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY timestamp_key = parameters[ pm4_constants. PARAMETER_CONSTANT_TIMESTAMP_KEY] if pm4_constants.PARAMETER_CONSTANT_TIMESTAMP_KEY in parameters else xes.DEFAULT_TIMESTAMP_KEY case_id_glue = parameters[ pm4_constants. PARAMETER_CONSTANT_CASEID_KEY] if pm4_constants.PARAMETER_CONSTANT_CASEID_KEY in parameters else CASE_CONCEPT_NAME parameters[pm4_constants.RETURN_EA_COUNT_DICT_AUTOFILTER] = True dataframe = attributes_filter.filter_df_keeping_spno_activities( dataframe, activity_key=activity_key, max_no_activities=constants.MAX_NO_ACTIVITIES) dataframe, end_activities = auto_filter.apply_auto_filter( dataframe, parameters=parameters) end_activities = list(end_activities.keys()) activities_count = attributes_filter.get_attribute_values( dataframe, activity_key, parameters=parameters) activities = list(activities_count.keys()) start_activities = list( start_activities_filter.get_start_activities( dataframe, parameters=parameters).keys()) dfg = df_statistics.get_dfg_graph(dataframe, activity_key=activity_key, timestamp_key=timestamp_key, case_id_glue=case_id_glue, sort_caseid_required=False, sort_timestamp_along_case_id=False) dfg = clean_dfg_based_on_noise_thresh( dfg, activities, decreasingFactor * constants.DEFAULT_DFG_CLEAN_MULTIPLIER, parameters=parameters) net, im, fm = inductive_miner.apply_dfg(dfg, parameters, activities=activities, start_activities=start_activities, end_activities=end_activities) spaths = get_shortest_paths(net) aggregated_statistics = get_decorations_from_dfg_spaths_acticount( net, dfg, spaths, activities_count, variant="frequency") gviz = pn_vis_factory.apply(net, im, fm, parameters={"format": "svg"}, variant="frequency", aggregated_statistics=aggregated_statistics) gviz_base64 = base64.b64encode(str(gviz).encode('utf-8')) ret_graph = get_graph.get_graph_from_petri(net, im, fm) return get_base64_from_gviz(gviz), export_petri_as_string( net, im, fm ), ".pnml", "parquet", activities, start_activities, end_activities, gviz_base64, ret_graph, "inductive", "freq", None, "", activity_key
def apply(log, parameters=None): """ Gets the Petri net through Inductive Miner, decorated by performance metric Parameters ------------ log Log parameters Parameters of the algorithm Returns ------------ base64 Base64 of an SVG representing the model model Text representation of the model format Format of the model """ if parameters is None: parameters = {} decreasingFactor = parameters[ "decreasingFactor"] if "decreasingFactor" in parameters else constants.DEFAULT_DEC_FACTOR activity_key = parameters[ pm4_constants. PARAMETER_CONSTANT_ACTIVITY_KEY] if pm4_constants.PARAMETER_CONSTANT_ACTIVITY_KEY in parameters else xes.DEFAULT_NAME_KEY # reduce the depth of the search done by token-based replay token_replay.MAX_REC_DEPTH = 1 token_replay.MAX_IT_FINAL1 = 1 token_replay.MAX_IT_FINAL2 = 1 token_replay.MAX_REC_DEPTH_HIDTRANSENABL = 1 log = attributes_filter.filter_log_on_max_no_activities( log, max_no_activities=constants.MAX_NO_ACTIVITIES, parameters=parameters) filtered_log = auto_filter.apply_auto_filter(log, parameters=parameters) activities_count = attributes_filter.get_attribute_values( filtered_log, activity_key) activities = list(activities_count.keys()) start_activities = list( start_activities_filter.get_start_activities( filtered_log, parameters=parameters).keys()) end_activities = list( end_activities_filter.get_end_activities(filtered_log, parameters=parameters).keys()) dfg = dfg_factory.apply(filtered_log, parameters=parameters) dfg = clean_dfg_based_on_noise_thresh( dfg, activities, decreasingFactor * constants.DEFAULT_DFG_CLEAN_MULTIPLIER, parameters=parameters) net, im, fm = inductive_miner.apply_dfg(dfg, parameters=parameters, activities=activities, start_activities=start_activities, end_activities=end_activities) #parameters["format"] = "svg" #gviz = pn_vis_factory.apply(net, im, fm, log=log, variant="performance", parameters=parameters) bpmn_graph, el_corr, inv_el_corr, el_corr_keys_map = petri_to_bpmn.apply( net, im, fm) aggregated_statistics = token_decoration.get_decorations( filtered_log, net, im, fm, parameters=parameters, measure="performance") bpmn_aggreg_statistics = convert_performance_map.convert_performance_map_to_bpmn( aggregated_statistics, inv_el_corr) #bpmn_graph = bpmn_embedding.embed_info_into_bpmn(bpmn_graph, bpmn_aggreg_statistics, "performance") bpmn_graph = bpmn_diagram_layouter.apply(bpmn_graph) bpmn_string = bpmn_exporter.get_string_from_bpmn(bpmn_graph) gviz = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "svg"}) gviz2 = bpmn_vis_factory.apply_petri( net, im, fm, aggregated_statistics=aggregated_statistics, variant="performance", parameters={"format": "dot"}) svg = get_base64_from_file(gviz.name) gviz_base64 = get_base64_from_file(gviz2.name) ret_graph = get_graph.get_graph_from_petri(net, im, fm) return svg, export_petri_as_string( net, im, fm ), ".pnml", "xes", activities, start_activities, end_activities, gviz_base64, ret_graph, "indbpmn", "perf", bpmn_string, ".bpmn", activity_key