def test_alphadoc1(self): from pm4py.log.importer import xes as xes_importer log = xes_importer.import_from_file_xes( "inputData\\running-example.xes") from pm4py.algo.alpha import factory as alpha_miner net, initial_marking, final_marking = alpha_miner.apply(log) from pm4py.models.petri import visualize as pn_viz gviz = pn_viz.graphviz_visualization(net, initial_marking=initial_marking, final_marking=final_marking)
def test_alphaMinerVisualizationFromXES(self): log, net, marking, fmarking = self.obtainPetriNetThroughAlphaMiner( os.path.join(INPUT_DATA_DIR, "running-example.xes")) log.sort() log = log.sample() log.insert_trace_index_as_event_attribute() petri_exporter.export_petri_to_pnml( net, marking, os.path.join(OUTPUT_DATA_DIR, "running-example.pnml")) os.remove(os.path.join(OUTPUT_DATA_DIR, "running-example.pnml")) gviz = pn_viz.graphviz_visualization(net) final_marking = petri.petrinet.Marking() for p in net.places: if not p.out_arcs: final_marking[p] = 1 [ traceIsFit, traceFitnessValue, activatedTransitions, placeFitness, reachedMarkings, enabledTransitionsInMarkings ] = token_replay.apply_log(log, net, marking, final_marking, enable_placeFitness=True)
time3 = time.time() print("time3 - time2: "+str(time3-time2)) #dataframe = df_filtering.filter_df_on_ncases(dataframe, case_id_glue="case:concept:name", max_no_cases=1000) time4 = time.time() print("time4 - time3: "+str(time4-time3)) #dataframe = df_filtering.filter_df_on_case_length(dataframe, case_id_glue="case:concept:name", min_trace_length=3, max_trace_length=50) print(dataframe) time5 = time.time() print("time5 - time4: "+str(time5-time4)) dataframe = csv_importer.convert_timestamp_columns_in_df(dataframe) time6 = time.time() print("time6 - time5: "+str(time6-time5)) #dataframe = dataframe.sort_values('time:timestamp') time7 = time.time() print("time7 - time6: "+str(time7-time6)) # show the filtered dataframe on the screen activities_count = df_statistics.get_activities_count(dataframe) [dfg_frequency, dfg_performance] = df_statistics.get_dfg_graph(dataframe, measure="both") #activities_count = df_statistics.get_activities_count(dataframe, activity_key="event") #[dfg_frequency, dfg_performance] = df_statistics.get_dfg_graph(dataframe, measure="both", case_id_glue="case", activity_key="event", timestamp_key="startTime") time8 = time.time() print("time8 - time7: "+str(time8-time7)) gviz = dfg_vis_factory.apply(dfg_frequency, activities_count=activities_count) gviz.view() net, initial_marking, final_marking = inductive_factory.apply_dfg(dfg_frequency) gviz = pn_viz.graphviz_visualization(net, initial_marking=initial_marking, final_marking=final_marking, debug=True) gviz.view() time9 = time.time() print("time9 - time8: "+str(time9-time8)) print("time9 - time1: "+str(time9-time1))
import time log = xes_importer.import_from_file_xes( '..\\tests\\inputData\\running-example.xes') #log = xes_importer.import_from_path_xes('a32f0n00.xes') net, marking, final_marking = alpha_factory.apply(log) for place in marking: print("initial marking " + place.name) final_marking = petri.petrinet.Marking() for p in net.places: if not p.out_arcs: final_marking[p] = 1 for place in final_marking: print("final marking " + place.name) gviz = pn_viz.graphviz_visualization(net, initial_marking=marking, final_marking=final_marking) gviz.view() log = log[0:min(100, len(log))] time0 = time.time() print("started token replay") [ traceIsFit, traceFitnessValue, activatedTransitions, placeFitness, reachedMarkings, enabledTransitionsInMarkings ] = token_replay.apply_log(log, net, marking, final_marking, enable_placeFitness=True, consider_remaining_in_fitness=False) for place in placeFitness:
#log = log_transform.transform_trace_log_to_event_log(log) #print('time to transform the log: %s' % (time.time() - start)) #print('new first event %s' % log[0]) #start = time.time() #log = log_instance.EventLog(sorted(log, key=lambda e: e['time:timestamp'], reverse=True), attributes=log.attributes, classifiers=log.classifiers, omni_present=log.omni_present, extensions=log.extensions) #print('time to sort the log on time stamp: %s' % (time.time() - start)) #print(log[0]) #start = time.time() #log = log_transform.transform_event_log_to_trace_log(log) #print('time to transform the log: %s' % (time.time() - start)) start = time.time() dfg = dfg_instance.apply(log) print('time to compute dfg: %s' % (time.time()-start)) start = time.time() cag = causal_instance.compute_causal_relations(dfg, causal_instance.CAUSAL_ALPHA) print('time to compute causal graph: %s' % (time.time() - start)) start = time.time() ''' net, initial_marking, final_marking = alpha_classic.apply( trace_log, 'Activity') print('time to compute alpha: %s' % (time.time() - start)) gviz = pn_viz.graphviz_visualization(net) gviz.view()