Return to the current

MINEPI algorithm - Example

This article will present the application of the MINEPI algorithm on a simple example.

EN

Example

For readability, episodes like <A,B><A, B> are written as ABAB.

Yesterday, you monitored 4 activities that you have done for 7 hours.

The 4 events are the following:

  • “M” : Listening to music
  • “E” : Eating
  • “S” : Sleeping
  • “C” : Coding

Your day looked like the following:

Minepi Example

With the MINEPI algorithm, try to identify the different episodes with the following constraints:

  • maxspan=3max_{span} = 3 means that the maximum duration of an episode is 3 hours (3 hours means potentially 4 events).
  • mingap=1min_{gap} = 1 means that 2 events must be separated by at least 1 hour. Simultaneous events are not allowed.
  • minfreq=2min_{freq} = 2 means that an episode must be present at least 2 times in the dataset.

Solution

Episodes of size 1

The first step is to identify frequent episodes of size 1. In our example, we have 4 events, so we have 4 episodes of size 1.

The candidate episodes of size 1 are:

C1={M,E,S,C}C_1 = \{M, E, S, C\}

  • MM is present 3 times: id(M)={1,3,5}id(M) = \{1, 3, 5\}
  • EE is present 2 times: id(E)={3,7}id(E) = \{3, 7\}
  • SS is present 1 time: id(S)={4}id(S) = \{4\}
  • CC is present 3 times: id(C)={2,5,6}id(C) = \{2, 5, 6\}

Therefore, the frequent episodes of size 1 are: F1={M,E,C}F_1 = \{M, E, C\}

Episodes of size 2

Starting here, we don’t have to look anymore at the sequence, we can just compute each frequency by looking at the size 1 results.

The candidates are, all the combinations of MM, EE and CC.

C2={MM,ME,MC,EM,EC,CM,CE,CC}C_2 = \{MM, ME, MC, EM, EC, CM, CE, CC\}

  • MMMM is present 2 times: id(MM)={(1,3),(3,5)}id(MM) = \{(1, 3), (3, 5)\}
  • MEME is present 2 times: id(ME)={(1,3),(5,7)}id(ME) = \{(1, 3), (5, 7)\} (not (3,3)(3, 3) because mingap=1min_{gap} = 1)
  • MCMC is present 3 times: id(MC)={(1,2),(3,5),(5,6)}id(MC) = \{(1, 2), (3, 5), (5, 6)\}
  • EMEM is present 1 time: id(EM)={(3,5)}id(EM) = \{(3, 5)\}
  • ECEC is present 1 time: id(EC)={(3,5)}id(EC) = \{(3, 5)\}
  • CMCM is present 1 time: id(CM)={(2,3)}id(CM) = \{(2, 3)\}
  • CECE is present 2 times: id(CE)={(2,3),(6,7)}id(CE) = \{(2, 3), (6, 7)\}
  • CCCC is present 2 times: id(CC)={(2,5),(5,6)}id(CC) = \{(2, 5), (5, 6)\}

The frequent episodes of size 2 are:

F2={MM,ME,MC,CE,CC}F_2 = \{MM, ME, MC, CE, CC\}

Episodes of size 3

The candidate episodes of size 3 are:

C3={MME,MMC,MCE,MCC,CCE}C_3 = \{MME, MMC, MCE, MCC, CCE\}

Note that if MEME was not in F2F_2, having MCMC and CECE would not have been sufficient to have MCEMCE in C3C_3.

  • MMEMME is present 1 time: id(MME)={(3,7)}id(MME) = \{(3,7)\}
  • MMCMMC is present 1 time: id(MMC)={(3,6)}id(MMC) = \{(3,6)\}
  • MCEMCE is present 2 times:id(MCE)={(1,3),(5,7)}id(MCE) = \{(1,3), (5, 7)\}
  • MCCMCC is present 1 time: id(MCC)={(3,6)}id(MCC) = \{(3, 6)\}
  • CCECCE is present 1 time: id(CCE)={(5,7)}id(CCE) = \{(5, 7)\}

The last frequent episode of size 3 is:

F3={MCE}F_3 = \{MCE\}

Episodes of size 4

They are no candidates for episodes of size 4.

Conclusion

The frequent episodes are:

i=13Fi={M,E,C,MM,ME,MC,CE,CC,MCE}\bigcup_{i=1}^3 F_i = \{M, E, C, MM, ME, MC, CE, CC, MCE\}

Source:

Mannila, Heikki et al. “Discovery of Frequent Episodes in Event Sequences.” Data Mining and Knowledge Discovery 1 (2004): 259-289.