0

Consider the input file be

25 27 29 25 27 29 25 27 29 25 27 29 25 27 28 

I want to extract the pattern 25 27 29. What are the algorithms that I can use to mine the pattern in a sequence like this? I'm willing to implement it using unsupervised learning techniques.

ThunderPunch
  • 483
  • 1
  • 4
  • 16

1 Answers1

0

This question is hard to answer as pattern and extracting might mean different things:

Is your pattern including the spaces between the numbers, or just the list of number themselves? Is the pattern exactly 25 27 29 or n n+2 n+4

Does extract mean finding the position? Removing it from the list?

Therefore, there are no algorithms or techniques as is it hard to understand what you are willing to do.

In a Python style and in a very general way (you can replace a, b and c with integers and make the list longer), you can go for :

list = [25, 27, 29, 25, 27, 29, 25, 27, 29, 25, 27, 29, 25, 27, 28]
ptn = [a, b, c]
position = []

for i, nb in enumerate(list):
    if i != len(list) - len(pattern);
         if nb == ptn[i] and list[i+1] == ptn[i+1] and list[i+2] == ptn[i+2]:
               position.append(i)
Igor OA
  • 387
  • 3
  • 13