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

The problem of eventually follows relationship #327

Closed Ichiruchan closed 2 years ago

Ichiruchan commented 2 years ago

I want filter my dataframe according to the order of list [A, B, C ...]. Actually, i could find a lot of functions to realize it. According to the comments in source code, I used from pm4py.algo.filtering.pandas.ltl.ltl_checker import eventually_follows and mode1 = eventually_follows(my_data, ["order", "operation"]). And the filtered result is strange 企业微信截图_b8731fa6-38c4-4393-b8dd-81e84900871f

fit-alessandro-berti commented 2 years ago

Dear Ichiruchan,

The eventually follows filter has had some problems in the previous releases. Please ensure to use the latest version of PM4Py (pip install -U pm4py).

Then you can use it as follows and it works as expected:

import pm4py import pandas as pd

dataframe = pd.read_csv("C:/running-example.csv") dataframe = pm4py.format_dataframe(dataframe) filtered_log = pm4py.filter_eventually_follows_relation(dataframe, [("register request", "check ticket", "reinitiate request")])

Ichiruchan commented 2 years ago

Actually, my version is image. I will try your suggestion. Thank you very much

Ichiruchan commented 2 years ago

I executed pip command. (And i think before this time, i have already used the latest version). It still gave me a wrong result . image

fit-alessandro-berti commented 2 years ago

Thank you for the detailed error description. We understood your problem. Before we release the proper fix, I would like to invite you to use the following command before the filter is applied:

dataframe = dataframe.reset_index()

Ichiruchan commented 2 years ago

Thank you for the detailed error description. We understood your problem. Before we release the proper fix, I would like to invite you to use the following command before the filter is applied:

dataframe = dataframe.reset_index()

Once i reseted index, the function runs correctly. I think the order of index is important for the follow function. So it is a good habit to sort timestamp with case id and reset index after sorting timestamp. Thanks a lot for your reply.

fit-alessandro-berti commented 2 years ago

Thank you for your bug signaling