def apply(log, parameters=None): """ Gets the performance HNet 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 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) start_activities_count = start_activities_filter.get_start_activities(filtered_log, parameters=parameters) end_activities_count = end_activities_filter.get_end_activities(filtered_log, parameters=parameters) activities = list(activities_count.keys()) start_activities = list(start_activities_count.keys()) end_activities = list(end_activities_count.keys()) dfg_freq = dfg_factory.apply(filtered_log, parameters=parameters) dfg_perf = dfg_factory.apply(filtered_log, variant="performance", parameters=parameters) heu_net = HeuristicsNet(dfg_freq, performance_dfg=dfg_perf, activities=activities, start_activities=start_activities, end_activities=end_activities, activities_occurrences=activities_count) heu_net.calculate(dfg_pre_cleaning_noise_thresh=constants.DEFAULT_DFG_CLEAN_MULTIPLIER * decreasingFactor) vis = heu_vis_factory.apply(heu_net, parameters={"format": "svg"}) vis2 = heu_vis_factory.apply(heu_net, parameters={"format": "dot"}) gviz_base64 = get_base64_from_file(vis2.name) return get_base64_from_file(vis.name), None, "", "xes", activities, start_activities, end_activities, gviz_base64, [], "heuristics", "perf", None, "", activity_key
def generate_heuristics_miner_net(xes_log): try: heu_net = heuristics_miner.apply_heu(xes_log) gviz = hn_vis_factory.apply(heu_net) hn_vis_factory.view(gviz) return {'heu_net': heu_net} except AttributeError: print("Please check your input values")
def test_heunet_running_example(self): # to avoid static method warnings in tests, # that by construction of the unittest package have to be expressed in such way self.dummy_variable = "dummy_value" log = xes_importer.import_log( os.path.join(INPUT_DATA_DIR, "running-example.xes")) heu_net = heuristics_miner.apply_heu(log) gviz = hn_vis_factory.apply(heu_net) del gviz
def execute_script(): log = xes_importer.apply( os.path.join("..", "tests", "compressed_input_data", "09_a32f0n00.xes.gz")) heu_net = heuristics_miner.apply_heu( log, parameters={"dependency_thresh": 0.99}) gviz = hn_vis_factory.apply(heu_net, parameters={"format": "svg"}) hn_vis_factory.view(gviz) net, im, fm = heuristics_miner.apply( log, parameters={"dependency_thresh": 0.99}) gviz2 = petri_vis_factory.apply(net, im, fm, parameters={"format": "svg"}) petri_vis_factory.view(gviz2)
def bot_hm(chat_id, dependency_threshold=0.99): log = get_current_log(chat_id) heu_net = heuristics_miner.apply_heu( log, parameters={"dependency_thresh": dependency_threshold}) gviz = hn_vis_factory.apply(heu_net) new_file, filename = tempfile.mkstemp(suffix="png") hn_vis_factory.save(gviz, filename) net, im, fm = heuristics_miner.apply( log, parameters={"dependency_thresh": dependency_threshold}) gviz = pn_vis_factory.apply(net, im, fm) new_file2, filename2 = tempfile.mkstemp(suffix="png") pn_vis_factory.save(gviz, filename2) return [filename, filename2]
def SPHeuristicsMiner(context): args = context.args inputFile = os.path.join(args.inputData, os.listdir(args.inputData)[0]) log = xes_importer.import_log(inputFile) heu_net = heuristics_miner.apply_heu( log, parameters={ "dependency_thresh": args.dependencyThresh, "and_measure_thresh": args.andMeasureThresh, "min_act_count": args.minActCount, "min_dfg_occurrences": args.minDfgOccurrences, "dfg_pre_cleaning_noise_thresh": args.dfgPreCleaningNoiseThresh, }, ) gviz = hn_vis_factory.apply(heu_net) hn_vis_factory.save(gviz, os.path.join(args.outputData, "heuristics-miner.png")) return args.outputData
a2 = pcaDataWeeksFrequency[w].loc[ pcaDataWeeksFrequency[w]['result_exam_1'] == 1, ['pc2']] b2 = pcaDataWeeksFrequency[w].loc[ pcaDataWeeksFrequency[w]['result_exam_1'] == 0, ['pc2']] t2, p2 = stats.ttest_ind(a2, b2) print('Week ' + str(w) + ':') print('--PC1: ' + 't-value: ' + str(t1) + ' p-value: ' + str(p1)) print('-- Excellent: ' + str(a1.mean()[0])) print('-- Weak: ' + str(b1.mean()[0])) print('--PC2: ' + 't-value: ' + str(t2) + ' p-value: ' + str(p2)) print('-- Excellent: ' + str(a2.mean()[0])) print('-- Weak: ' + str(b2.mean()[0])) #Heuristic Miner from pm4py.objects.conversion.log import factory as conversion_factory Log = pd.concat(workingWeekLog) ex1_personal_log_1_converted = conversion_factory.apply( Log.loc[Log['org:resource'].isin(ex3_excellent.index)]) ex1_personal_log_2_converted = conversion_factory.apply( Log.loc[Log['org:resource'].isin(ex3_weak.index)]) from pm4py.algo.discovery.heuristics import factory as heuristics_miner from pm4py.visualization.heuristics_net import factory as hn_vis_factory excellent_heu_net = heuristics_miner.apply_heu( ex1_personal_log_2_converted, parameters={"dependency_thresh": 0.0}) gviz = hn_vis_factory.apply(excellent_heu_net) hn_vis_factory.view(gviz)
def apply(dataframe, parameters=None): """ Gets the performance HNet 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 ws_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=ws_constants.MAX_NO_ACTIVITIES) dataframe, end_activities_count = auto_filter.apply_auto_filter( dataframe, parameters=parameters) activities_count = attributes_filter.get_attribute_values( dataframe, activity_key, parameters=parameters) start_activities_count = start_activities_filter.get_start_activities( dataframe, parameters=parameters) activities = list(activities_count.keys()) start_activities = list(start_activities_count.keys()) end_activities = list(end_activities_count.keys()) dfg_frequency, dfg_performance = df_statistics.get_dfg_graph( dataframe, case_id_glue=case_id_glue, activity_key=activity_key, timestamp_key=timestamp_key, measure="both", sort_caseid_required=False, sort_timestamp_along_case_id=False) heu_net = HeuristicsNet(dfg_frequency, performance_dfg=dfg_performance, activities=activities, start_activities=start_activities, end_activities=end_activities, activities_occurrences=activities_count) heu_net.calculate(dfg_pre_cleaning_noise_thresh=ws_constants. DEFAULT_DFG_CLEAN_MULTIPLIER * decreasingFactor) vis = heu_vis_factory.apply(heu_net, parameters={"format": "svg"}) vis2 = heu_vis_factory.apply(heu_net, parameters={"format": "dot"}) gviz_base64 = get_base64_from_file(vis2.name) return get_base64_from_file(vis.name), None, "", "parquet", activities, start_activities, end_activities, gviz_base64, [], "heuristics", "perf", None, "", activity_key
from pm4py.algo.discovery.heuristics import factory as heuristics_miner from pm4py.objects.log.importer.csv import factory as csv_importer from pm4py.objects.log.adapters.pandas import csv_import_adapter from pm4py.objects.conversion.log import factory as conversion_factory from pm4py.visualization.petrinet import factory as pn_vis_factory from pm4py.visualization.heuristics_net import factory as hn_vis_factory from pm4py.util import constants import os os.environ["PATH"] += os.pathsep + 'C:/Archivos de Programa/GraphViz/bin/' dataframe = csv_import_adapter.import_dataframe_from_path( 'cursos.csv', sep=",") log = conversion_factory.apply(dataframe, parameters={constants.PARAMETER_CONSTANT_CASEID_KEY: "case:concept:name", constants.PARAMETER_CONSTANT_ACTIVITY_KEY: "concept:name", constants.PARAMETER_CONSTANT_TIMESTAMP_KEY: "time:timestamp"}) net = heuristics_miner.apply_heu( log, parameters={"dependency_thresh": 0.99}) gviz = hn_vis_factory.apply(net) hn_vis_factory.view(gviz)
def create_heuristics_miner(self): heu_net = heuristics_miner.apply_heu(self._log, parameters={"dependency_thresh": 0.99}) gviz = hn_vis_factory.apply(heu_net, parameters={"format": "pdf"}) self._create_image(gviz, "heuristic_miner")