This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discovery_test.py
143 lines (130 loc) · 7.44 KB
/
discovery_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import pandas as pd
from case_attribute_discovery.config import DEFAULT_CSV_IDS
from case_attribute_discovery.discovery import discover_case_attributes
def test_discover_case_attributes_discrete():
# Create custom dataframe
event_log = pd.DataFrame(
data=[
{'case_id': "c1", 'Activity': "Start", 'end_time': 2, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c1", 'Activity': "Do something", 'end_time': 4, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c1", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c1", 'Activity': "End", 'end_time': 8, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c2", 'Activity': "Start", 'end_time': 2, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c2", 'Activity': "Do something", 'end_time': 4, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c2", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c2", 'Activity': "End", 'start_time': 7, 'end_time': 8, 'case_att_1': "THE WORLD", 'case_att_2': "DIO"},
{'case_id': "c3", 'Activity': "Start", 'end_time': 2, 'case_att_1': "THE WORLD", 'case_att_2': "Avdol"},
{'case_id': "c3", 'Activity': "Do something", 'end_time': 4, 'case_att_1': "THE WORLD", 'case_att_2': "Avdol"},
{'case_id': "c3", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': "THE WORLD", 'case_att_2': "Avdol"},
{'case_id': "c3", 'Activity': "End", 'end_time': 8, 'case_att_1': "THE WORLD", 'case_att_2': "Avdol's father"},
{'case_id': "c4", 'Activity': "Start", 'end_time': 2, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c4", 'Activity': "Do something", 'end_time': 4, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c4", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c4", 'Activity': "End", 'end_time': 8, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c5", 'Activity': "Start", 'end_time': 2, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c5", 'Activity': "Do something", 'end_time': 4, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c5", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"},
{'case_id': "c5", 'Activity': "End", 'end_time': 8, 'case_att_1': "STAR PLATINUM", 'case_att_2': "Jotaro"}
]
)
# Get case attributes
case_attributes = discover_case_attributes(event_log, DEFAULT_CSV_IDS)
# Check they are the expected ones
assert case_attributes == [
{
'name': "case_att_1",
'type': 'discrete',
'values': [
{'key': "THE WORLD", 'probability': 0.6},
{'key': "STAR PLATINUM", 'probability': 0.4}
]
}
]
# Get case attributes with noise (allow up to an average 10% of different attribute values in the traces)
case_attributes = discover_case_attributes(event_log, DEFAULT_CSV_IDS, confidence_threshold=0.9)
# Check they are the expected ones
assert case_attributes == [
{
'name': "case_att_1",
'type': 'discrete',
'values': [
{'key': "THE WORLD", 'probability': 0.6},
{'key': "STAR PLATINUM", 'probability': 0.4}
]
},
{
'name': "case_att_2",
'type': 'discrete',
'values': [
{'key': "DIO", 'probability': 0.4},
{'key': "Avdol", 'probability': 0.2},
{'key': "Jotaro", 'probability': 0.4}
]
}
]
def test_discover_case_attributes_continuous():
# Create custom dataframe
event_log = pd.DataFrame(
data=[
{'case_id': "c1", 'Activity': "Start", 'end_time': 2, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c1", 'Activity': "Do something", 'end_time': 4, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c1", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c1", 'Activity': "End", 'end_time': 8, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c2", 'Activity': "Start", 'end_time': 2, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c2", 'Activity': "Do something", 'end_time': 4, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c2", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c2", 'Activity': "End", 'end_time': 8, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c3", 'Activity': "Start", 'end_time': 2, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c3", 'Activity': "Do something", 'end_time': 4, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c3", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c3", 'Activity': "End", 'start_time': 7, 'end_time': 8, 'case_att_1': 1.0, 'case_att_2': 36},
{'case_id': "c4", 'Activity': "Start", 'end_time': 2, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c4", 'Activity': "Do something", 'end_time': 4, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c4", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c4", 'Activity': "End", 'end_time': 8, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c5", 'Activity': "Start", 'end_time': 2, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c5", 'Activity': "Do something", 'end_time': 4, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c5", 'Activity': "Do another something", 'end_time': 6, 'case_att_1': 1.0, 'case_att_2': 35},
{'case_id': "c5", 'Activity': "End", 'end_time': 8, 'case_att_1': 1.0, 'case_att_2': 35}
]
)
# Get case attributes
case_attributes = discover_case_attributes(event_log, DEFAULT_CSV_IDS)
# Check they are the expected ones
assert case_attributes == [
{
'name': "case_att_1",
'type': 'continuous',
'values': {
'distribution_name': "fix",
'distribution_params': [
{'value': 1.0}
]
}
}
]
# Get case attributes with noise (allow up to an average 10% of different attribute values in the traces)
case_attributes = discover_case_attributes(event_log, DEFAULT_CSV_IDS, confidence_threshold=0.9)
# Check they are the expected ones
assert case_attributes == [
{
'name': "case_att_1",
'type': 'continuous',
'values': {
'distribution_name': "fix",
'distribution_params': [
{'value': 1.0}
]
}
},
{
'name': "case_att_2",
'type': 'continuous',
'values': {
'distribution_name': "fix",
'distribution_params': [
{'value': 35}
]
}
}
]