## 3 Shift Time Clustering on Event Logs
However, in Algorithm 1, we refer to the event with start and complete lifecycle. An event \(e\in E\) has a number of properties such as _caseid_, _activity_, _resource_, _start_, and _complete timestamp_. * Resource \(R\) be a set of all possible resource names, where \(\textit{res}\in E\to R\) assigning resources to events. \(R=\{r_{1},r_{2},r_{3},\dots,r_{n}\}\). * Group rows of an event by resource and order by start time \(G\) is a set of subset event group by the resources. \(G=\{\{e_{1},e_{2},e_{3},\dots,e_{x}\}\to r(e)=r1,\{e_{5},e_{6},e_{7},\dots,e_{ y}\}\to r(e)=r2,\dots\}\), each subset of events is ordered by start time attribute. * Splitting \(G\) of set into another subset \(SG\) is a set of subset event group after splitting. \(SG=\{\{e_{1},e_{2},\ldots,e_{(x-a)}\}\to r(e)=r1,\{e_{(x-a+1)},e_{(x-a+2)},e_{(x-a+3) },\ldots,e_{x}\}\to r(e)=r1,\ldots\}\), where \(e_{x-a}\) and \(e_{x-a+1}\) have the gap \(\geq 8\) h
* The array of object data \(SOB\) is a set of object data (array of object data). \(SOB=\{OB_{1},OB_{2},OB_{3},\ldots,OB_{n}\}\), where each \(OB_{i}\) have \(\{start,completion,duration\}\) information. Start and completion time in \(OB_{i}\) is contained only time (hour/minutes/seconds) without any date information. The start and the completion in \(OB_{i}\) are gathered from the subset event explained previously. Take the start time of the first event in each subset as a start for \(OB_{i}\) and take the end time of the last event in each subset as a completion. As explained in the above algorithm, we consider only the time without the date to cluster the data. The date is neglected because, in shift time clustering, working hours that start today at time, for example, 08:00 should be considered the same as other working hours that started yesterday or last week also at the time 08:00. This is reasonable for shift time clustering because the critical aspect is the time, but not the date. In addition to time information, we include the distance (duration of working hours) in the input. Clustering the data considering only the time but not the date is a trivial task but should be performed carefully. The distance between two different times could not be calculated using only a general distance function, as shown in Figure 3. The distance between time 23 and time 18 is 5 based on Figure 3 and based on normal calculation \(|23-18|=5\). However, the distance between time 23 and time 1 is 2 based on Figure 3, but if we calculate the distance normally, it becomes 21, \(|23-2|=21\) (which is not correct). We need to modify the distance function between times \(t_{i}\) and \(t_{j}\) to calculate the distance accurately. The symbol \(tr\) here refers to the time threshold for a specific time unit. For example, if the time unit is hours, \(tr\) is 24, and if the time unit is minutes, \(tr\) is 1440. The distance function of time, which always generates a positive value, can be shown in the following equation:  
\[D(i,j)=\min(|t_{i}-t_{j}|,tr+\min(t_{i},t_{j})-\max(t_{i},t_{j})) \tag{1}\]  
Theorem 1. \(D(i,j)\) in Equation (1) is a distance metric. The Equation (1) is a distance metric if it is a non-negative function \(D(i,j)\) and satisfies several properties based on the theorem of metrics as follow [16]:  
* The non-negativity \(D(i,i)\geq 0\),
* The identity property \(D(i,i)=0\),
* The symmetry property, \(D(i,j)=D(j,i)\), and
* The triangle inequality, \(D(i,j)+D(j,k)\geq D(i,k)\)  
\(D(i,j)\) in Equation (1) is a non-negative function because no input combination can yield a negative result. \(D(i,i)=\min(|t_{i}-t_{i}|,tr+\min(t_{i},t_{i})-\max(t_{i},t_{i}))=0\). Therefore, \(D\) satisfies the identity property. As we use the absolute value and the minimum and maximum values between two  
Figure 3: Description of distance based on time. input variables, changing the order of the input will not yield different results. This indicates that \(D\) also satisfies the symmetry property. We now prove that \(D\) satisfies the triangle inequality as well.