Commit 72cec316 authored by Debjit Pal's avatar Debjit Pal
Browse files

Adding changes to include time of occurence of the events

parent 102e64fc
......@@ -11,8 +11,8 @@ class Item():
'''
def __init__(
self,
Item,
Name,
Time
):
self.Item = Item
self.Name = Name
self.Time = Time
......@@ -6,6 +6,7 @@ Paper: PrefixSpan: Mining Sequential Patterns Efficiently by Prefix-Projected Pa
'''
from Constraints import *
from Item import *
class ReadData():
def __init__(
......@@ -26,7 +27,10 @@ class ReadData():
elements = line.lstrip().rstrip().split(',')
itemSet = []
for e in elements:
itemSet.append(e.split())
Items_ = e.split()
for Item__ in Items_:
splits = Item__.split('@')
itemSet.append(Item(splits[0], splits[1]))
SDB[SID] = itemSet
SID = SID + 1
return SDB
......
a,a b c,a c,d,c f
a d,c,b c,a e
e f,a b,d f,c,b
e,g,a f,c,b,c
a@1,a@2 b@2 c@2,a@3 c@3,d@4,c@5 f@5
a@1 d@1,c@2,b@3 c@3,a@4 e@4
e@1 f@1,a@2 b@2,d@3 f@3,c@4,b@5
e@1,g@2,a@3 f@3,c@4,b@4,c@5
......@@ -52,14 +52,15 @@ if __name__ == "__main__":
for key in SDB.keys():
SDB_.append(SDB[key])
print SDB_
# Algorithm 1 of Prefix Span Paper. Call PrefixSpan with Empty Sequence
# AllPatterns stores all Sequential Pattern with their support
AllPatterns = []
if constraints_file is not None:
AllPatterns = PrefixSpan.PrefixSpanWithConstraints(SeqPattern([], sys.maxint), SDB_, min_sup, Constraints)
else:
AllPatterns = PrefixSpan.PrefixSpan(SeqPattern([], sys.maxint), SDB_, min_sup)
##AllPatterns = []
##if constraints_file is not None:
## AllPatterns = PrefixSpan.PrefixSpanWithConstraints(SeqPattern([], sys.maxint), SDB_, min_sup, Constraints)
##else:
## AllPatterns = PrefixSpan.PrefixSpan(SeqPattern([], sys.maxint), SDB_, min_sup)
# Used sorting help from here: https://wiki.python.org/moin/HowTo/Sorting
AllPatternsSorted = sorted(AllPatterns, key=lambda Pattern: Pattern.Support, reverse=True)
for Pattern_ in AllPatternsSorted:
print ReadData.PrintPatternInStringFormat(Pattern_.Sequence, 1) + ' :: Support : ' + str(Pattern_.Support) + ' :: Length : ' + str(Pattern_.Length)
##AllPatternsSorted = sorted(AllPatterns, key=lambda Pattern: Pattern.Support, reverse=True)
##for Pattern_ in AllPatternsSorted:
## print ReadData.PrintPatternInStringFormat(Pattern_.Sequence, 1) + ' :: Support : ' + str(Pattern_.Support) + ' :: Length : ' + str(Pattern_.Length)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment