# Semi-Automated Approach for Building Event Logs for Process Mining from Relational Database
## 2 Background
### Evaluation Metrics  
The following metrics are used to calculate the time consumed in executing the activities at the case and event levels.  
Average time of cases (ATC): calculates the average time of the duration of the traces \(T\) in the event log \(L\), where \(\frac{1}{|T|}\sum_{e_{j}\in T}^{|T|}(e_{j+1}.timestamp-e_{j}.timestamp)\) is the average timeof the duration of the trace \(T\), while \(\sum_{e_{j}\in T}^{|T|}(e_{j+1}.timestamp-e_{j}.timestamp)\) is the total time of the duration of the traces \(T\), which is obtained by adding the duration of each of the events within the trace \(T\). We calculate the ATC as follows (Equation (1)).  
\[ATC=\frac{1}{\mid L\mid}\sum_{T\in L}^{\mid L\mid}\frac{1}{\mid T\mid}\sum_{e_{j }\in T}^{|T|}(e_{j+1}.timestamp-e_{j}.timestamp) \tag{1}\]  
Average time number of events (ATE): calculates the average time of the duration of each event \(e\in E\) in the entire event log \(L\). The time it takes for each of the \(e\) events in each of the traces is added (\(successor(e).timestamp-e.timestamp\)); where \(successor(e)\) refers to the next event of event \(e\in T\), and \(lg\) is the total of times event \(e\) appears in the event log \(L\).  
\[ATE=e\in E(\frac{1}{\mid lg\mid}\sum_{T\in L}^{\mid L\mid}\big{\{} successor(e).timestamp-e.timestamp,\ (lg=lg+1)\quad if\quad e\in T\ \big{\}}) \tag{2}\]  
The quality of the process models discovered from event logs built using the proposed framework (see Section 3) is evaluated using metrics defined below.  
Precision: this metric indicates how much additional behavior the process model allows that was not seen in the event log; the discovered model should not allow a behavior other than what is found in the event log [28; 29]. We calculate the precision as follows (Equation (3)):  
\[Qp=1-\frac{\sum_{nodes\_visited}\#visits*(\#outgoing\_edges-\#used\_edges \_by\_replay)}{\sum_{nodes\_visited}\#visits*\#outgoing\_edges} \tag{3}\]  
where \(\sum_{nodes\_visited}\) refers to a sum of each node which counts the total number of times visited (#visits) by subtracting the total of its output paths (#\(outgoing\_edges\)) minus the total of those output paths visited in the replay of the model (#used_edges_by_replay), divided by the product of the multiplication of the sum of the nodes visited \(\sum_{nodes\_visited}\)#visits by the total of the exit paths (#\(outgoing\_edges\)).  
Recall: it measures the degree to which all cases within the event log can be reproduced by the discovered process model [28; 29]. We calculate the recall as follows (Equation (4)):  
\[rp=\frac{\sum_{e\in L}(1-\frac{\textit{replay}(\sigma)}{\textit{length}( \sigma)})}{\mid L\mid} \tag{4}\]  
where it is calculated from a division of the sum of the length of the case reproducible by the discovered model between the length of the case, divided by the total number of cases in the event log.  
Generalization: estimates how well the process model describes the system's behavior and not just the relationship between the event log and the observed system behavior. The idea of generalization is that if all parts of the process model are used frequently, the model is likely to be generic [28; 30]. To calculate this measure following equation is used (Equation (5)):  
\[Qg=1-\frac{\sum_{nodes}(\sqrt{\textit{executions}})^{-1}}{\textit{#nodes\_in \_model}} \tag{5}\]  
where \(\sum_{nodes}(\sqrt{\textit{executions}})^{-1}\) indicates the sum of the square root of the total number of repetitions of each node to the power of \(-1\) (to normalize it to a value between 0 and 1), divided by the total number of nodes of the process model (#\(nodes\_in\_model\)).