pm4py / pm4py-core

Public repository for the PM4Py (Process Mining for Python) project.
https://pm4py.fit.fraunhofer.de
GNU General Public License v3.0
722 stars 286 forks source link

NoneType when discovering with Heuristic Miner #90

Closed lsabi closed 5 years ago

lsabi commented 5 years ago

Hi,

I'm using the heuristic miner with a small log. Probably due to the settings: "dependency_thresh": 0.5, and "min_act_count": 5, in the parameters when discovering, the graph is empty and I get the following error:

File "/home/user/.local/lib/python3.7/site-packages/pm4py/algo/discovery/heuristics/factory.py", line 110, in apply_heu return VERSIONS_HEU[variant](log, parameters=parameters) File "/home/user/.local/lib/python3.7/site-packages/pm4py/algo/discovery/heuristics/versions/classic.py", line 197, in apply_heu parameters=parameters) File "/home/user/.local/lib/python3.7/site-packages/pm4py/algo/discovery/heuristics/versions/classic.py", line 258, in apply_heu_dfg loops_length_two_thresh=loops_length_two_thresh) File "/home/user/.local/lib/python3.7/site-packages/pm4py/objects/heuristics_net/net.py", line 133, in calculate for el in self.dfg: TypeError: 'NoneType' object is not iterable

Wouldn't it be better to raise a warning and return an empty graph?

Thanks.

Javert899 commented 5 years ago

Sorry, I could not replicate the bug in any condition (log, stream, dataframe).

CODE: from pm4py.objects.log.importer.xes import factory as xes_importer from pm4py.algo.discovery.heuristics import factory as heu_miner from pm4py.objects.log.adapters.pandas import csv_import_adapter from pm4py.objects.log.importer.csv import factory as csv_importer

first try with 1

MIN_ACTI_COUNT = 1

log = xes_importer.apply("C:\running-example.xes") hnet = heu_miner.apply_heu(log, parameters={"min_act_count": MIN_ACTI_COUNT}) print(hnet) pn, im, fm = heu_miner.apply(log, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

df = csv_import_adapter.import_dataframe_from_path("C:\running-example.csv") pn, im, fm = heu_miner.apply(df, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

stream = csv_importer.apply("C:\running-example.csv") pn, im, fm = heu_miner.apply(stream, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

later try with 1000 to see if there is bug

MIN_ACTI_COUNT = 1000

log = xes_importer.apply("C:\running-example.xes") hnet = heu_miner.apply_heu(log, parameters={"min_act_count": MIN_ACTI_COUNT}) print(hnet) pn, im, fm = heu_miner.apply(log, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

df = csv_import_adapter.import_dataframe_from_path("C:\running-example.csv") pn, im, fm = heu_miner.apply(df, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

stream = csv_importer.apply("C:\running-example.csv") pn, im, fm = heu_miner.apply(stream, parameters={"min_act_count": MIN_ACTI_COUNT}) print(pn.places)

OUTPUT: {'register request': (node:register request connections:{examine casually:[0.75], check ticket:[0.6666666666666666], examine thoroughly:[0.5]}), 'examine casually': (node:examine casually connections:{decide:[0.6666666666666666]}), 'check ticket': (node:check ticket connections:{decide:[0.8571428571428571]}), 'examine thoroughly': (node:examine thoroughly connections:{decide:[0.5]}), 'decide': (node:decide connections:{reinitiate request:[0.75], pay compensation:[0.75], reject request:[0.75]}), 'reinitiate request': (node:reinitiate request connections:{examine thoroughly:[0.5], check ticket:[0.5], examine casually:[0.5]}), 'pay compensation': (node:pay compensation connections:{}), 'reject request': (node:reject request connections:{})} {splace_in_examine thoroughly_0, pre_examine casually, splace_in_examine thoroughly_1, pre_check ticket, pre_reinitiate request, splace_in_examine casually_0, intplace_decide, splace_in_decide_examine casually_0, intplace_reinitiate request, splace_in_decide_check ticket_0, splace_in_examine casually_1, splace_in_decide_2, pre_examine thoroughly, pre_pay compensation, splace_in_check ticket_0, pre_reject request, intplace_register request, splace_in_check ticket_1, source0, pre_decide, sink0} {splace_in_decide_check ticket_0, splace_in_check ticket_1, splace_in_examine thoroughly_0, splace_in_examine casually_1, splace_in_examine casually_0, source0, splace_in_decide_2, sink0, pre_examine casually, splace_in_decide_examine casually_0, pre_reinitiate request, splace_in_examine thoroughly_1, pre_pay compensation, intplace_decide, pre_check ticket, intplace_reinitiate request, intplace_register request, pre_examine thoroughly, splace_in_check ticket_0, pre_reject request, pre_decide} {source0, sink0, intplace_decide, splace_in_decide_examine casually_0, pre_check ticket, intplace_reinitiate request, splace_in_decide_check ticket_0, pre_examine casually, splace_in_decide_2, pre_examine thoroughly, pre_pay compensation, splace_in_check ticket_0, pre_reject request, intplace_register request, splace_in_examine casually_1, splace_in_check ticket_1, pre_decide, splace_in_examine casually_0, splace_in_examine thoroughly_0, splace_in_examine thoroughly_1, pre_reinitiate request} {} {source0, sink0} {source0, sink0} {source0, sink0}

Javert899 commented 5 years ago

As not said, found the root cause of the bug.

It was due to the DFG pre-filtering. In the case the pre-filtering is applied, and the DFG is empty, a None was returned as filtered DFG.

Issue fixed in the 'hotfixes' branch, will be released in next release.

lsabi commented 5 years ago

Great,

Sorry for not providing a minimum working example, but at the moment of opening the issue I was in a rush.

Is there a release scheduled for the hotfix?

Thanks

Javert899 commented 5 years ago

Bug resolved in release 1.1.19