Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/hotfixes' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Apr 8, 2024
2 parents 272f425 + 6781a90 commit c86a335
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pm4py/algo/conformance/declare/variants/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def apply_list(projected_log: List[List[str]], model: Dict[str, Dict[Any, Dict[s
__check_non_coexistence(trace, model, ret, parameters)

ret["no_dev_total"] = len(ret["deviations"])
ret["dev_fitness"] = 1 - ret["no_dev_total"] / ret["no_constr_total"]
ret["dev_fitness"] = 1.0 - ret["no_dev_total"] / ret["no_constr_total"] if ret["no_constr_total"] > 0 else 1.0
ret["is_fit"] = ret["no_dev_total"] == 0

conf_cases.append(ret)
Expand Down
21 changes: 11 additions & 10 deletions pm4py/algo/discovery/declare/variants/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,19 +577,20 @@ def get_rules_from_rules_df(rules_df, parameters: Optional[Dict[Any, Any]] = Non
min_support_ratio = float(supp) / float(len(rules_df)) * auto_selection_multiplier
min_confidence_ratio = float(len(col[col == 1])) / float(supp) * auto_selection_multiplier

for col_name in rules_df:
col = rules_df[col_name]
supp = len(col[col != 0])
if rules_df is not None and len(rules_df) > 0:
for col_name in rules_df:
col = rules_df[col_name]
supp = len(col[col != 0])

if supp > len(rules_df) * min_support_ratio:
conf = len(col[col == 1])
if supp > len(rules_df) * min_support_ratio:
conf = len(col[col == 1])

if conf > supp * min_confidence_ratio:
rule, key = __col_to_dict_rule(col_name)
if rule not in rules:
rules[rule] = {}
if conf > supp * min_confidence_ratio:
rule, key = __col_to_dict_rule(col_name)
if rule not in rules:
rules[rule] = {}

rules[rule][key] = {"support": supp, "confidence": conf}
rules[rule][key] = {"support": supp, "confidence": conf}

return rules

Expand Down
10 changes: 8 additions & 2 deletions pm4py/algo/discovery/log_skeleton/variants/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def always_after(logs_traces, all_activs, noise_threshold=0):
for k in rs:
rs[k] = rs[k] * logs_traces[trace]
ret0 += rs
ret = set(x for x, y in ret0.items() if y >= all_activs[x[0]] * (1.0 - noise_threshold))
first_count = Counter()
for x, y in ret0.items():
first_count[x[0]] += y
ret = set(x for x, y in ret0.items() if y >= first_count[x[0]] * (1.0 - noise_threshold))
return ret


Expand Down Expand Up @@ -136,7 +139,10 @@ def always_before(logs_traces, all_activs, noise_threshold=0):
for k in rs:
rs[k] = rs[k] * logs_traces[trace]
ret0 += rs
ret = set(x for x, y in ret0.items() if y >= all_activs[x[0]] * (1.0 - noise_threshold))
first_count = Counter()
for x, y in ret0.items():
first_count[x[0]] += y
ret = set(x for x, y in ret0.items() if y >= first_count[x[0]] * (1.0 - noise_threshold))
return ret


Expand Down
9 changes: 4 additions & 5 deletions pm4py/algo/transformation/log_to_trie/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ def apply(log: Union[EventLog, pd.DataFrame], parameters: Optional[Dict[Union[st
trie = c
match = True
break
if match:
continue
node = Trie(label=activity, parent=trie, depth=trie.depth + 1)
trie.children.append(node)
trie = node
if not match:
node = Trie(label=activity, parent=trie, depth=trie.depth + 1)
trie.children.append(node)
trie = node
if i == len(variant) - 1:
trie.final = True
return root

0 comments on commit c86a335

Please sign in to comment.