-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ft-1398-sampling-simplified-interface' into 'integration'
FT 1398 Sampling in simplified interface See merge request process-mining/pm4py/pm4py-core!556
- fhg-2.2.18
- 2.7.13
- 2.7.12.4
- 2.7.12
- 2.7.11.11
- 2.7.11.10
- 2.7.11.9
- 2.7.11.8
- 2.7.11.7
- 2.7.11.6
- 2.7.11.5
- 2.7.11.4
- 2.7.11.3
- 2.7.11.2
- 2.7.11.1
- 2.7.11
- 2.7.10.3
- 2.7.10.2
- 2.7.10.1
- 2.7.9.4
- 2.7.9.3
- 2.7.9.1
- 2.7.8.4
- 2.7.8.3
- 2.7.8.2
- 2.7.8.1
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5.3
- 2.7.5.2
- 2.7.5.1
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.31
- 2.2.30
- 2.2.29
- 2.2.28
- 2.2.27
- 2.2.26
- 2.2.25
- 2.2.24
- 2.2.23
- 2.2.22
- 2.2.21
- 2.2.20
- 2.2.19.2
- 2.2.19.1
- 2.2.19
- 2.2.18
- 2.2.17.1
- 2.2.17
Showing
4 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from pm4py.objects.ocel.util import attributes_names, extended_table, flattening, related_objects, related_events, filtering_utils, log_ocel | ||
from pm4py.objects.ocel.util import attributes_names, extended_table, flattening, related_objects, related_events, filtering_utils, log_ocel, sampling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from enum import Enum | ||
from pm4py.util import exec_utils | ||
from pm4py.objects.ocel import constants | ||
import random | ||
from pm4py.objects.ocel.util import filtering_utils | ||
from copy import copy | ||
from pm4py.objects.ocel.obj import OCEL | ||
from typing import Optional, Dict, Any | ||
|
||
|
||
class Parameters(Enum): | ||
OBJECT_ID = constants.PARAM_OBJECT_ID | ||
EVENT_ID = constants.PARAM_EVENT_ID | ||
NUM_ENTITIES = "num_entities" | ||
|
||
|
||
def sample_ocel_events(ocel: OCEL, parameters: Optional[Dict[Any, Any]] = None) -> OCEL: | ||
""" | ||
Keeps a sample of the events of an object-centric event log | ||
Parameters | ||
------------------ | ||
ocel | ||
Object-centric event log | ||
parameters | ||
Parameters of the algorithm, including: | ||
- Parameters.EVENT_ID => event identifier | ||
- Parameters.NUM_EVENTS => number of events | ||
Returns | ||
------------------ | ||
sampled_ocel | ||
Sampled object-centric event log | ||
""" | ||
if parameters is None: | ||
parameters = {} | ||
|
||
event_id_column = exec_utils.get_param_value(Parameters.EVENT_ID, parameters, ocel.event_id_column) | ||
num_entities = exec_utils.get_param_value(Parameters.NUM_ENTITIES, parameters, 100) | ||
|
||
events = list(ocel.events[event_id_column].unique()) | ||
num_events = min(len(events), num_entities) | ||
|
||
random.shuffle(events) | ||
picked_events = events[:num_events] | ||
|
||
ocel = copy(ocel) | ||
ocel.events = ocel.events[ocel.events[event_id_column].isin(picked_events)] | ||
|
||
return filtering_utils.propagate_event_filtering(ocel, parameters=parameters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters