Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pro
CRDiS
Commits
043fd98d
Commit
043fd98d
authored
7 years ago
by
Kamil Jurek
Browse files
Options
Download
Email Patches
Plain Diff
apriori
parent
be2f7052
master
alternative_rules
refactored
rules
No related merge requests found
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
.idea/workspace.xml
+221
-228
.idea/workspace.xml
configs/numerical_1
+4
-1
configs/numerical_1
detectors/detector.py
+105
-64
detectors/detector.py
detectors/page_hinkley_detector.py
+6
-0
detectors/page_hinkley_detector.py
plots/plot_seque.png
+0
-0
plots/plot_seque.png
rules_mining/apriori.py
+132
-0
rules_mining/apriori.py
rules_mining/test_rule_miner.py
+2
-2
rules_mining/test_rule_miner.py
sequences/sequence_2018_03_24-13.19.49.csv
+1801
-0
sequences/sequence_2018_03_24-13.19.49.csv
test_pagehinkley_detector.py
+7
-4
test_pagehinkley_detector.py
with
2278 additions
and
299 deletions
+2278
-299
.idea/workspace.xml
View file @
043fd98d
This diff is collapsed.
Click to expand it.
configs/numerical_1
View file @
043fd98d
attr = 'attr_1';value=4;domain = [1,2,3,4]; from = -800; to = -500; probability = 0.90
attr = 'attr_1';value=2;domain = [1,2,3,4]; from = -500; to = -300; probability = 0.8
0
attr = 'attr_1';value=2;domain = [1,2,3,4]; from = -500; to = -300; probability = 0.8
5
attr = 'attr_1';value=3;domain = [1,2,3,4]; from = -300; to = 0; probability = 0.85
attr = 'attr_2';value=2;domain = [1,2,3,4]; from = -600; to = -400; probability = 0.90
attr = 'attr_2';value=1;domain = [1,2,3,4]; from = -400; to = -200; probability = 0.85
attr = 'attr_2';value=3;domain = [1,2,3,4]; from = -200; to = 0; probability = 0.85
attr = 'attr_3';value=4;domain = [1,2,3,4]; probability = 0.01
This diff is collapsed.
Click to expand it.
detectors/detector.py
View file @
043fd98d
...
...
@@ -7,6 +7,8 @@ class ChangeDetector(object):
self
.
is_change_detected
=
False
self
.
sequence_size
=
0
self
.
sequence
=
[]
self
.
current_value
=
0
self
.
previous_value
=
0
def
update
(
self
,
new_value
):
self
.
sequence
.
append
(
new_value
)
...
...
@@ -30,29 +32,39 @@ class ChangeDetector(object):
return
self
.
get_parameters
()
class
OnlineSimulator
(
object
):
def
__init__
(
self
,
change_detector
,
sequence
):
self
.
sequence
=
sequence
self
.
change_detector
=
change_detector
self
.
sequence_size
=
len
(
sequence
)
self
.
detected_change_points
=
[]
def
__init__
(
self
,
change_detectors
,
sequences
,
seqs_names
):
#self.sequence = sequence
self
.
sequences
=
sequences
self
.
sequences_names
=
seqs_names
#self.change_detector = change_detector
self
.
change_detectors
=
change_detectors
self
.
sequence_size
=
len
(
sequences
[
0
])
self
.
detected_change_points
=
[[]
for
i
in
range
(
len
(
self
.
sequences
))]
self
.
parameters_history
=
[
defaultdict
(
list
)
for
i
in
range
(
len
(
self
.
sequences
))]
def
get_detected_changes
(
self
):
return
self
.
detected_change_points
def
run
(
self
,
plot
=
True
,
**
kwargs
):
sequence
=
self
.
sequence
detector
=
self
.
change_detector
parameters_history
=
defaultdict
(
list
)
for
i
,
value
in
enumerate
(
sequence
):
res
=
detector
.
step
(
value
)
for
k
,
v
in
res
.
items
():
parameters_history
[
k
].
append
(
v
)
if
detector
.
is_change_detected
is
True
:
self
.
detected_change_points
.
append
(
i
)
parameters_history
=
[]
p
=
defaultdict
(
list
)
for
i
in
range
(
0
,
self
.
sequence_size
):
for
j
,
seq
in
enumerate
(
self
.
sequences
):
detector
=
self
.
change_detectors
[
j
]
value
=
seq
[
i
]
res
=
detector
.
step
(
value
)
for
k
,
v
in
res
.
items
():
p
[
k
].
append
(
v
)
if
i
==
self
.
sequence_size
-
1
:
parameters_history
.
append
(
p
)
print
(
parameters_history
)
if
detector
.
is_change_detected
is
True
:
change_point
=
ChangePoint
(
detector
.
previous_value
,
detector
.
current_value
,
i
)
self
.
detected_change_points
[
j
].
append
(
change_point
)
print
(
self
.
sequences_names
[
j
],
"changed from:"
,
change_point
.
from_
,
"to:"
,
change_point
.
to_
,
"at: "
,
change_point
.
at_
)
def
dict_to_arrays
(
ddict
):
new_dict
=
{}
...
...
@@ -60,8 +72,32 @@ class OnlineSimulator(object):
new_dict
[
k
]
=
np
.
array
(
v
)
return
new_dict
parameters_history
=
dict_to_arrays
(
parameters_history
)
self
.
parameters_history
=
parameters_history
for
i
in
range
(
0
,
len
(
self
.
sequences
)):
parameters_history
[
i
]
=
dict_to_arrays
(
parameters_history
[
i
])
self
.
parameters_history
[
i
]
=
parameters_history
[
i
]
#sequence = self.sequence
#detector = self.change_detector
# parameters_history = defaultdict(list)
#
# for i, value in enumerate(sequence):
# res = detector.step(value)
#
# for k, v in res.items():
# parameters_history[k].append(v)
#
# if detector.is_change_detected is True:
# self.detected_change_points.append(i)
#
# def dict_to_arrays(ddict):
# new_dict = {}
# for k, v in ddict.items():
# new_dict[k] = np.array(v)
# return new_dict
#
# parameters_history = dict_to_arrays(parameters_history)
# self.parameters_history = parameters_history
if
plot
is
True
:
self
.
display_results
(
**
kwargs
)
...
...
@@ -69,50 +105,55 @@ class OnlineSimulator(object):
return
detector
.
is_change_detected
def
display_results
(
self
,
sequence_name
=
'Sequence'
,
**
kwargs
):
sequence
=
self
.
sequence
detector
=
self
.
change_detector
parameters_history
=
self
.
parameters_history
plotcount
=
1
+
len
(
parameters_history
)
fig
,
axes
=
plt
.
subplots
(
nrows
=
plotcount
,
ncols
=
1
,
sharex
=
True
,
figsize
=
(
12
,
plotcount
*
3
))
# Plot the sequence
if
plotcount
>
1
:
ax
=
axes
[
0
]
elif
plotcount
==
1
:
ax
=
axes
ax
.
plot
(
sequence
,
'b.'
)
ax
.
plot
(
sequence
,
'b-'
,
alpha
=
0.25
)
ax
.
set_title
(
sequence_name
)
ax
.
set_ylim
(
np
.
nanmin
(
sequence
)
*
.
5
,
np
.
nanmax
(
sequence
)
*
1.5
)
ax
.
set_xlim
(
0
,
len
(
sequence
))
xl
=
ax
.
get_xticks
()
ticks
=
xl
-
int
(
2
/
3
*
len
(
sequence
))
ax
.
set_xticklabels
(
ticks
)
# Plot a horizontal line where the change_point is detected
for
s
in
self
.
detected_change_points
:
ax
.
vlines
(
x
=
s
,
ymin
=
0
,
ymax
=
ax
.
get_ylim
()[
1
],
colors
=
'r'
,
linestyles
=
'dotted'
)
# Plot each parameter
for
ii
,
(
res_name
,
res_values
)
in
enumerate
(
parameters_history
.
items
()):
ax
=
axes
[
ii
+
1
]
ax
.
plot
(
res_values
,
'g.'
,
alpha
=
0.7
)
ax
.
set_title
(
"Parameter #{}: {}"
.
format
(
ii
+
1
,
res_name
))
# ax.set_ylim(
# np.nanmin(res_values)*0.5,
# np.nanmax(res_values)*1.5)
for
p
in
self
.
detected_change_points
:
ax
.
vlines
(
x
=
p
,
ymin
=
0
,
ymax
=
ax
.
get_ylim
()[
1
],
for
i
in
range
(
0
,
len
(
self
.
sequences
)):
sequence
=
self
.
sequences
[
i
]
detector
=
self
.
change_detectors
[
i
]
parameters_history
=
self
.
parameters_history
[
i
]
detected_change_points
=
self
.
detected_change_points
[
i
]
plotcount
=
1
+
len
(
parameters_history
)
fig
,
axes
=
plt
.
subplots
(
nrows
=
plotcount
,
ncols
=
1
,
sharex
=
True
,
figsize
=
(
12
,
plotcount
*
3
))
# Plot the sequence
if
plotcount
>
1
:
ax
=
axes
[
0
]
elif
plotcount
==
1
:
ax
=
axes
ax
.
plot
(
sequence
,
'b.'
)
ax
.
plot
(
sequence
,
'b-'
,
alpha
=
0.25
)
ax
.
set_title
(
sequence_name
)
ax
.
set_ylim
(
np
.
nanmin
(
sequence
)
*
.
5
,
np
.
nanmax
(
sequence
)
*
1.5
)
ax
.
set_xlim
(
0
,
len
(
sequence
))
xl
=
ax
.
get_xticks
()
ticks
=
xl
-
int
(
2
/
3
*
len
(
sequence
))
ax
.
set_xticklabels
(
ticks
)
# Plot a horizontal line where the change_point is detected
for
change_point
in
detected_change_points
:
ax
.
vlines
(
x
=
change_point
.
at_
,
ymin
=
0
,
ymax
=
ax
.
get_ylim
()[
1
],
colors
=
'r'
,
linestyles
=
'dotted'
)
# Plot each parameter
for
ii
,
(
res_name
,
res_values
)
in
enumerate
(
parameters_history
.
items
()):
ax
=
axes
[
ii
+
1
]
ax
.
plot
(
res_values
,
'g.'
,
alpha
=
0.7
)
ax
.
set_title
(
"Parameter #{}: {}"
.
format
(
ii
+
1
,
res_name
))
for
change_poin
in
detected_change_points
:
ax
.
vlines
(
x
=
change_poin
.
at_
,
ymin
=
0
,
ymax
=
ax
.
get_ylim
()[
1
],
colors
=
'r'
,
linestyles
=
'dotted'
)
plt
.
show
()
class
ChangePoint
(
object
):
def
__init__
(
self
,
from_
,
to_
,
at_
):
self
.
from_
=
from_
self
.
to_
=
to_
self
.
at_
=
at_
\ No newline at end of file
This diff is collapsed.
Click to expand it.
detectors/page_hinkley_detector.py
View file @
043fd98d
import
numpy
as
np
import
scipy
as
sp
from
scipy
import
signal
from
statistics
import
mode
from
detector
import
ChangeDetector
class
PageHinkleyDetector
(
ChangeDetector
):
...
...
@@ -13,10 +14,12 @@ class PageHinkleyDetector(ChangeDetector):
self
.
mean_
=
0
self
.
sum_
=
0
self
.
n
=
0
self
.
subseq
=
[]
self
.
is_change_detected
=
False
def
update
(
self
,
new_value
):
super
(
PageHinkleyDetector
,
self
).
update
(
new_value
)
self
.
subseq
.
append
(
new_value
)
self
.
n
+=
1
self
.
mean_
=
self
.
mean_
+
(
new_value
-
self
.
mean_
)
/
self
.
n
self
.
sum_
=
self
.
sum_
*
self
.
alpha
+
new_value
-
self
.
mean_
-
self
.
delta
...
...
@@ -24,10 +27,13 @@ class PageHinkleyDetector(ChangeDetector):
def
check_change
(
self
,
new_value
):
self
.
is_change_detected
=
False
if
np
.
abs
(
self
.
sum_
)
>
self
.
lambd
:
self
.
previous_value
=
mode
(
self
.
subseq
)
self
.
current_value
=
mode
(
self
.
subseq
[
-
9
:])
self
.
is_change_detected
=
True
self
.
reset
()
def
reset
(
self
):
self
.
n
=
0
self
.
subseq
=
[]
self
.
mean_
=
0
self
.
sum_
=
0
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plots/plot_seque.png
View replaced file @
be2f7052
View file @
043fd98d
25.1 KB
|
W:
0px
|
H:
0px
29.1 KB
|
W:
0px
|
H:
0px
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
rules_mining/apriori.py
0 → 100644
View file @
043fd98d
import
numpy
as
np
def
loadDataSet
():
return
[[
1
,
1
,
3
,
4
],
[
2
,
3
,
5
,
1
],
[
1
,
1
,
2
,
3
,
5
],
[
2
,
5
]]
def
createC1
(
dataSet
):
C1
=
[]
for
transaction
in
dataSet
:
for
item
in
transaction
:
if
not
[
item
]
in
C1
:
C1
.
append
([
item
])
#C1.sort()
#return list(map(frozenset, C1))
return
C1
def
contains
(
small
,
big
):
for
i
in
range
(
len
(
big
)
-
len
(
small
)
+
1
):
for
j
in
range
(
len
(
small
)):
if
big
[
i
+
j
]
!=
small
[
j
]:
break
else
:
return
i
,
i
+
len
(
small
)
return
False
print
(
contains
([
1
,
3
,
4
],
[
1
,
3
,
4
]))
def
scanD
(
D
,
Ck
,
minSupport
):
ssCnt
=
{}
for
tid
in
D
:
for
can
in
Ck
:
if
contains
(
can
,
tid
):
#print(can)
if
not
tuple
(
can
)
in
ssCnt
:
ssCnt
[
tuple
(
can
)]
=
1
else
:
ssCnt
[
tuple
(
can
)]
+=
1
numItems
=
float
(
len
(
D
))
retList
=
[]
supportData
=
{}
for
key
in
ssCnt
:
support
=
ssCnt
[
key
]
/
numItems
if
support
>=
minSupport
:
retList
.
append
(
key
)
supportData
[
key
]
=
support
return
retList
,
supportData
dataSet
=
loadDataSet
()
# print(dataSet)
#
C1
=
createC1
(
dataSet
)
# print(C1)
#
D
=
dataSet
#print(D)
#
L1
,
suppDat0
=
scanD
(
D
,
C1
,
0.5
)
print
(
L1
)
def
aprioriGen
(
Lk
,
k
):
#creates Ck
retList
=
[]
lenLk
=
len
(
Lk
)
#print("Lk:", Lk)
for
i
in
range
(
lenLk
):
for
j
in
range
(
lenLk
):
# L1 = list(Lk[i])[:k-2]
# L2 = list(Lk[j])[:k-2]
# print(L1)
# print(L2)
# #L1.sort()
# #L2.sort()
# if L1==L2: #if first k-2 elements are equal
retList
.
append
(
Lk
[
i
]
+
Lk
[
j
])
#set union
#print(retList)
return
retList
def
apriori
(
dataSet
,
minSupport
=
0.5
):
C1
=
createC1
(
dataSet
)
D
=
dataSet
L1
,
supportData
=
scanD
(
D
,
C1
,
minSupport
)
L
=
[
L1
]
k
=
2
while
(
len
(
L
[
k
-
2
])
>
0
):
Ck
=
aprioriGen
(
L
[
k
-
2
],
k
)
print
(
"Cl:"
,
Ck
)
Lk
,
supK
=
scanD
(
D
,
Ck
,
minSupport
)
#scan DB to get Lk
print
(
"Lk:"
,
Lk
)
supportData
.
update
(
supK
)
L
.
append
(
Lk
)
k
+=
1
return
L
,
supportData
L
,
suppData
=
apriori
(
dataSet
)
print
(
L
)
print
(
suppData
)
def
generateRules
(
L
,
supportData
,
minConf
=
0.7
):
#supportData is a dict coming from scanD
bigRuleList
=
[]
for
i
in
range
(
1
,
len
(
L
)):
#only get the sets with two or more items
for
freqSet
in
L
[
i
]:
H1
=
[
frozenset
([
item
])
for
item
in
freqSet
]
if
(
i
>
1
):
rulesFromConseq
(
freqSet
,
H1
,
supportData
,
bigRuleList
,
minConf
)
else
:
calcConf
(
freqSet
,
H1
,
supportData
,
bigRuleList
,
minConf
)
return
bigRuleList
def
calcConf
(
freqSet
,
H
,
supportData
,
brl
,
minConf
=
0.7
):
prunedH
=
[]
#create new list to return
for
conseq
in
H
:
conf
=
supportData
[
freqSet
]
/
supportData
[
freqSet
-
conseq
]
#calc confidence
if
conf
>=
minConf
:
print
(
freqSet
-
conseq
,
'-->'
,
conseq
,
'conf:'
,
conf
)
brl
.
append
((
freqSet
-
conseq
,
conseq
,
conf
))
prunedH
.
append
(
conseq
)
return
prunedH
def
rulesFromConseq
(
freqSet
,
H
,
supportData
,
brl
,
minConf
=
0.7
):
m
=
len
(
H
[
0
])
if
(
len
(
freqSet
)
>
(
m
+
1
)):
#try further merging
Hmp1
=
aprioriGen
(
H
,
m
+
1
)
#create Hm+1 new candidates
Hmp1
=
calcConf
(
freqSet
,
Hmp1
,
supportData
,
brl
,
minConf
)
if
(
len
(
Hmp1
)
>
1
):
#need at least two sets to merge
rulesFromConseq
(
freqSet
,
Hmp1
,
supportData
,
brl
,
minConf
)
#L, suppData = apriori(dataSet, minSupport=0.5)
#rules= generateRules(L,suppData, minConf=0.7)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
rules_mining/test_rule_miner.py
View file @
043fd98d
...
...
@@ -2,9 +2,9 @@ from rules_miner import RulesMiner
sequences
=
[
#
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
[
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
3
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
2
,
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and it.
test_pagehinkley_detector.py
View file @
043fd98d
...
...
@@ -10,8 +10,10 @@ from detector import OnlineSimulator
from
page_hinkley_detector
import
PageHinkleyDetector
#Numerical data
df
=
pd
.
read_csv
(
'sequences/sequence_2017_11_28-18.07.57.csv'
)
seq
=
np
.
array
(
df
[
'attr_1'
])
#sequences/sequence_2017_11_28-18.07.57.csv
df
=
pd
.
read_csv
(
'sequences/sequence_2018_03_24-13.19.49.csv'
)
seq1
=
np
.
array
(
df
[
'attr_1'
])
seq2
=
np
.
array
(
df
[
'attr_2'
])
# Symbolic data
# df = pd.read_csv('sequences/sequence_2017_11_22-19.35.27.csv')
...
...
@@ -19,8 +21,9 @@ seq = np.array(df['attr_1'])
# seq = en.encode(seq)
# seq = [np.abs(np.mean(e)) for e in seq]
detector
=
PageHinkleyDetector
(
delta
=
0.001
,
lambd
=
20
,
alpha
=
0.99
)
simulator
=
OnlineSimulator
(
detector
,
seq
)
detector1
=
PageHinkleyDetector
(
delta
=
0.001
,
lambd
=
20
,
alpha
=
0.99
)
detector2
=
PageHinkleyDetector
(
delta
=
0.001
,
lambd
=
20
,
alpha
=
0.99
)
simulator
=
OnlineSimulator
([
detector1
,
detector2
],
[
seq1
,
seq2
],
[
"attr_1"
,
"attr_2"
])
simulator
.
run
()
actual_change_points
=
np
.
array
([
600
,
800
,
1000
,
1300
,
1500
,
1800
])
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help