def execute_script(): # loads the dataframe from the CSV file csv_path = os.path.join("..", "tests", "input_data", "running-example.csv") df = csv_import_adapter.import_dataframe_from_path(csv_path) # calculates the Matrix Container object mco = sna_transformer.apply(df) # calculates the Handover of Work matrix hw_matrix = handover_of_work.apply(mco) # calculates the Similar Activities matrix sim_act_matrix = similar_activities.apply(mco) # shows the Handover of Work graph gviz = sna_vis_factory.apply(mco, hw_matrix, parameters={"format": "svg"}) sna_vis_factory.view(gviz) # shows the Similar Activities graph gviz = sna_vis_factory.apply(mco, sim_act_matrix, parameters={ "format": "svg", "threshold": 0.0 }) sna_vis_factory.view(gviz) # calculates the Real Handover of Work matrix real_hw_matrix = real_handover_of_work.apply(mco, parameters={"format": "svg"}) gviz = sna_vis_factory.apply(mco, real_hw_matrix)
def apply(log, variant="handover", parameters=None): """ Gets the Social Network according to the specified metric and arc threshold Parameters ------------- log Log variant Variant of the algorithm to use parameters Possible parameters of the algorithm (arc threshold) Returns ------------- sna Social Network representation """ if parameters is None: parameters = {} parameters["metric_normalization"] = True metric = sna_factory.apply(log, variant=variant, parameters=parameters) pyvis_repr = sna_vis_factory.apply(metric, variant="pyvis", parameters=parameters) return open(pyvis_repr).read()
def execute_script(): # loads the log from XES file log_path = os.path.join("..", "tests", "input_data", "receipt.xes") log = xes_importer.apply(log_path) # calculates the Matrix Container object mco = sna_transformer.apply(log) # calculates the Handover of Work matrix hw_matrix = handover_of_work.apply(mco) # calculates the Similar Activities matrix sim_act_matrix = similar_activities.apply(mco) # shows the Handover of Work graph gviz = sna_vis_factory.apply(mco, hw_matrix, variant="pyvis") sna_vis_factory.view(gviz, variant="pyvis") # shows the Similar Activities graph gviz = sna_vis_factory.apply(mco, sim_act_matrix, parameters={"threshold": 0.0}, variant="pyvis") sna_vis_factory.view(gviz, variant="pyvis")
def execute_script(): log = xes_importer.apply( os.path.join("..", "tests", "input_data", "running-example.xes")) hw_values = sna_factory.apply(log, variant="handover") wt_values = sna_factory.apply(log, variant="working_together") sub_values = sna_factory.apply(log, variant="subcontracting") ja_values = sna_factory.apply(log, variant="jointactivities") gviz_sub = pn_vis_factory.apply(sub_values, variant="networkx", parameters={"format": "svg"}) gviz_hw = pn_vis_factory.apply(hw_values, variant="pyvis") gviz_wt = pn_vis_factory.apply(wt_values, variant="networkx", parameters={"format": "svg"}) gviz_ja = pn_vis_factory.apply(ja_values, variant="pyvis") pn_vis_factory.view(gviz_sub, variant="networkx") pn_vis_factory.view(gviz_hw, variant="pyvis") pn_vis_factory.view(gviz_wt, variant="networkx") pn_vis_factory.view(gviz_ja, variant="pyvis")
def work_handover(): try: print( "Kindly enter the name of your formatted file\n" "Note: please include .csv file extension and make sure that input file has no blank rows or columns" ) filename = str(input()) dataframe = csv_import_adapter.import_dataframe_from_path(filename, sep=",") from pm4py.objects.conversion.log import factory as conversion_factory # lib to convert csv to xes log = conversion_factory.apply(dataframe) from pm4py.algo.enhancement.sna import factory as sna_factory hw_values = sna_factory.apply(log, variant="handover") from pm4py.visualization.sna import factory as sna_vis_factory gviz_hw_py = sna_vis_factory.apply(hw_values, variant="pyvis") sna_vis_factory.view(gviz_hw_py, variant="pyvis") except FileNotFoundError: print("Please check your file name")