Python Forum
Process Mining: OCEL creation from CSV with PM4PY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Process Mining: OCEL creation from CSV with PM4PY
#1
Hi,
I am currently trying to create an object-centric event log from a csv-file, which I am using the PM4PY library to. This is the function I created to achieve that:
def read_and_convert_to_ocel(filename):
    # Read the CSV file into a DataFrame
    ev = pd.read_csv(filename)

    # Convert the "ocel:timestamp" column to datetime format
    ev['ocel:timestamp'] = pd.to_datetime(ev['ocel:timestamp'], format='%Y-%m-%d %H:%M:%S')

    # Convert all columns except "ocel:timestamp" to string
    cols_to_convert = ev.columns.drop('ocel:timestamp')
    ev[cols_to_convert] = ev[cols_to_convert].astype(str)

    # Create event log from DataFrame
    el = pm4py.convert.convert_to_event_log(ev, 'ocel:eid')

    # List of object types
    column_headers = [
        'ocel:type:1',
        'ocel:type:2',
        'ocel:type:3',
    ]

    # List of event attributes
    event_attributes = ['attribute1', 'attribute2', 'attribute3']

    # Convert event log to OCEL
    ocel = pm4py.convert.convert_log_to_ocel(el, 'ocel:activity', 'ocel:timestamp', column_headers, ',', event_attributes)
    return ocel
The input file is a pre-processed csv-file according to ocel 1.0 specifications. An example CSV file can be found under "Eventlogs" here: https://ocel-standard.org/1.0/
I came across two problems, while using this function:
1. I am not able to specify object attributes in the log conversion to ocel. I asked the support line why this is not possible , but have not received an answer yet.
2. Some of the object:types contain 'nan' values. In the outputted OCEL, these 'nan' values are treated as objects of that object type and distort the outcome.

Has anybody here worked with PM4PY in the context of OCEL creation before and could provide some intuition? Help would be much appreciated.
I am not even sure if my approach to OCEL creation is the right way to do it, since it is more commonly practiced to transform a CSV-file to JSON-OCEL or XML-OCEL format beforehand, which I tried, but were not able to accomplish due to inexperience with both data formats.

Best regards and thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Libraries for Process Mining PythonBeginner1 1 25,101 Jan-21-2023, 11:56 AM
Last Post: Larz60+
  Is there a Python text mining script to classify text with multiple classifications? Endearment 0 1,871 Oct-21-2019, 07:50 PM
Last Post: Endearment

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020