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
d4b9865e
Commit
d4b9865e
authored
7 years ago
by
Kamil Jurek
Browse files
Options
Download
Email Patches
Plain Diff
improved rules detection
parent
026fafb9
master
alternative_rules
rules
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
configs/numerical_6
+2
-2
configs/numerical_6
detectors/detector.py
+157
-29
detectors/detector.py
sequences/sequence_2018_04_13-22.33.30.csv
+1201
-0
sequences/sequence_2018_04_13-22.33.30.csv
test_rules_detecting.py
+36
-4
test_rules_detecting.py
with
1396 additions
and
35 deletions
+1396
-35
configs/numerical_6
View file @
d4b9865e
attr = 'attr_1';value=2;domain = [1,2,3,4]; from = -800; to = -500; probability = 0.90
attr = 'attr_1';value=3;domain = [1,2,3,4]; from = -500; to = 0; probability = 0.85
attr = 'attr_1';value=3;domain = [1,2,3,4]; from = -500; to =
-20
0; probability = 0.85
attr = 'attr_2';value=4;domain = [1,2,3,4,5]; from = -800; to = -300; probability = 0.90
attr = 'attr_2';value=5;domain = [1,2,3,4,5]; from = -300; to = 0; probability = 0.85
attr = 'attr_2';value=5;domain = [1,2,3,4,5]; from = -300; to =
-10
0; probability = 0.85
attr = 'attr_3';value=1;domain = [1,2,3,4,5]; from = -800; to = -100; probability = 0.85
attr = 'attr_3';value=4;domain = [1,2,3,4,5]; from = -100; to = 0; probability = 0.95
attr = 'attr_4';value=6;domain = [1,2,3,4,5,6]; probability = 1.0
\ No newline at end of file
This diff is collapsed.
Click to expand it.
detectors/detector.py
View file @
d4b9865e
...
...
@@ -38,7 +38,7 @@ class OnlineSimulator(object):
self
.
change_detectors
=
change_detectors
self
.
sequence_size
=
len
(
sequences
[
0
])
self
.
detected_change_points
=
[[]
for
i
in
range
(
len
(
self
.
sequences
))]
self
.
rules
=
[[]
for
i
in
range
(
len
(
self
.
sequences
))]
self
.
rules
_sets
=
[
set
()
for
i
in
range
(
len
(
self
.
sequences
))]
self
.
parameters_history
=
[
defaultdict
(
list
)
for
i
in
range
(
len
(
self
.
sequences
))]
self
.
target_index
=
len
(
self
.
sequences
)
-
1
...
...
@@ -46,7 +46,7 @@ class OnlineSimulator(object):
return
self
.
detected_change_points
def
get_rules
(
self
):
return
self
.
rules
return
self
.
rules
_sets
def
run
(
self
,
plot
=
True
,
**
kwargs
):
parameters_history
=
[
defaultdict
(
list
)
for
i
in
range
(
len
(
self
.
sequences
))]
...
...
@@ -107,39 +107,118 @@ class OnlineSimulator(object):
return
detector
.
is_change_detected
def
search_rules
(
self
,
current_index
):
prev_prev_change_point_target
=
self
.
detected_change_points
[
self
.
target_index
][
-
3
]
if
len
(
self
.
detected_change_points
[
self
.
target_index
])
>
2
else
None
prev_change_point_target
=
self
.
detected_change_points
[
self
.
target_index
][
-
2
]
window_begin
=
round_to_hundreds
(
prev_prev_change_point_target
.
at_
)
if
prev_prev_change_point_target
!=
None
else
0
window_end
=
round_to_hundreds
(
prev_change_point_target
.
at_
)
for
m
,
change_point_list
in
enumerate
(
self
.
detected_change_points
[:
-
1
]):
# abandoning last seq, as it is target for now
prev_prev_change_point_target
=
self
.
detected_change_points
[
self
.
target_index
][
-
3
]
if
len
(
self
.
detected_change_points
[
self
.
target_index
])
>
2
else
None
prev_change_point_target
=
self
.
detected_change_points
[
self
.
target_index
][
-
2
]
lhs
=
[]
for
n
,
change_point
in
enumerate
(
change_point_list
):
prev_prev_change_point_index
=
prev_prev_change_point_target
.
at_
if
prev_prev_change_point_target
!=
None
else
0
prev_change_point_index
=
prev_change_point_target
.
at_
if
round_to_hundreds
(
change_point
.
at_
)
>=
prev_prev_change_point_index
and
round_to_hundreds
(
change_point
.
at_
)
<=
prev_change_point_index
:
lhs_elem_len
=
change_point
.
prev_value_len_
if
lhs_elem_len
>
0
:
lhs_elem
=
LHS_element
(
round_to_hundreds
(
change_point
.
prev_value_len_
),
change_point
.
prev_value
,
self
.
sequences_names
[
m
])
lhs
.
append
(
lhs_elem
)
points_before_window
,
points_in_window
,
points_after_window
=
self
.
get_change_points_in_window
(
m
,
window_begin
,
window_end
)
# no change points in window
if
len
(
points_in_window
)
==
0
:
lhs_elem
=
LHS_element
(
round_to_hundreds
(
window_end
-
window_begin
),
points_before_window
[
-
1
].
curr_value
,
self
.
sequences_names
[
m
])
lhs
.
append
(
lhs_elem
)
else
:
if
points_in_window
[
0
].
prev_value_len
<
window_end
:
for
point
in
points_in_window
:
lhs_elem
=
LHS_element
(
round_to_hundreds
(
point
.
prev_value_len_
),
point
.
prev_value
,
point
.
attr_name
)
lhs
.
append
(
lhs_elem
)
if
points_in_window
[
-
1
].
at_
<
window_end
:
lhs_elem
=
LHS_element
(
round_to_hundreds
(
window_end
-
points_in_window
[
-
1
].
at_
),
points_in_window
[
-
1
].
curr_value
,
points_in_window
[
-
1
].
attr_name
)
lhs
.
append
(
lhs_elem
)
# for n, change_point in enumerate(change_point_list):
# if round_to_hundreds(change_point.at_) > window_begin:
# if round_to_hundreds(change_point.at_) < window_end:
# lhs_elem = LHS_element(round_to_hundreds(change_point.prev_value_len_),
# change_point.prev_value,
# self.sequences_names[m])
# lhs.append(lhs_elem)
#print(lhs_elem)
#
# else:
# if not is_last_lhs:
# is_last_lhs = True
# last_lhs_elem_len = window_end - change_point.at_
# last_lhs_elem = LHS_element(round_to_hundreds(last_lhs_elem_len),
# change_point_list[n-1].curr_value,
# self.sequences_names[m])
# lhs.append(last_lhs_elem)
# #print("current i:",current_index)
# #print("change_point.prev_value_len_:", change_point.prev_value_len_)
# last_lhs_elem_len = prev_change_point_index - change_point_list[n-1].at_
# print("last lhs elem len:", last_lhs_elem_len)
# if last_lhs_elem_len > 0:
# last_lhs_elem = LHS_element(round_to_hundreds(last_lhs_elem_len),
# change_point_list[n-1].curr_value,
# self.sequences_names[m])
# lhs.append(last_lhs_elem)
# #print(last_lhs_elem)
# last change_point
if
n
==
len
(
change_point_list
)
-
1
:
last_lhs_elem_len
=
current_index
-
change_point_list
[
n
-
1
].
at_
#print(last_lhs_elem_len)
if
last_lhs_elem_len
>
0
:
last_lhs_elem
=
LHS_element
(
round_to_hundreds
(
last_lhs_elem_len
),
change_point_list
[
n
-
1
].
curr_value
,
self
.
sequences_names
[
m
])
lhs
.
append
(
last_lhs_elem
)
# print(last_lhs_elem)
# print(len(change_point_list) - 2)
# if n == len(change_point_list) - 2:
# last_lhs_elem_len = current_index - change_point_list[n - 2].at_
# print("last lhs elem len:", last_lhs_elem_len)
# if last_lhs_elem_len > 0:
# last_lhs_elem = LHS_element(round_to_hundreds(last_lhs_elem_len),
# change_point_list[n - 2].curr_value,
# self.sequences_names[m])
# lhs.append(last_lhs_elem)
# print(last_lhs_elem)
# no change points in window
# if len(lhs) == 0:
# lhs_elem = LHS_element(round_to_hundreds(window_end - window_begin),
# change_point.curr_value,
# self.sequences_names[m])
# lhs.append(lhs_elem)
rhs_elem
=
LHS_element
(
round_to_hundreds
(
self
.
detected_change_points
[
self
.
target_index
][
-
1
].
prev_value_len_
),
self
.
detected_change_points
[
self
.
target_index
][
-
1
].
prev_value
,
self
.
detected_change_points
[
self
.
target_index
][
-
1
].
attr_name
)
rule
=
Rule
(
lhs
,
rhs_elem
)
self
.
rules
.
append
(
rule
)
print
(
rule
)
is_new_rule
=
True
for
r
in
self
.
rules_sets
[
m
]:
if
r
==
rule
:
print
(
"rule already in set"
)
is_new_rule
=
False
r
.
set_last_occurence
(
current_index
)
r
.
increment_occurrences
()
print
(
r
)
if
is_new_rule
:
print
(
"new rule"
)
rule
.
set_last_occurence
(
current_index
)
rule
.
increment_occurrences
()
self
.
rules_sets
[
m
].
add
(
rule
)
print
(
rule
)
# if rule in self.rules_sets[m]:
# print("rule already in set")
# rule.set_last_occurence(current_index)
# rule.increment_occurrences()
# else:
# print("new rule")
# rule.set_last_occurence(current_index)
# rule.increment_occurrences()
#
# self.rules_sets[m].add(rule)
def
display_results
(
self
,
sequence_name
=
'Sequence'
,
**
kwargs
):
for
i
in
range
(
0
,
len
(
self
.
sequences
)):
...
...
@@ -189,6 +268,20 @@ class OnlineSimulator(object):
plt
.
show
()
def
get_change_points_in_window
(
self
,
seq_index
,
window_begin
,
window_end
):
points_in_window
=
[]
points_before_window
=
[]
points_after_window
=
[]
for
n
,
change_point
in
enumerate
(
self
.
detected_change_points
[
seq_index
]):
if
round_to_hundreds
(
change_point
.
at_
)
>
window_begin
:
if
round_to_hundreds
(
change_point
.
at_
)
<
window_end
:
points_in_window
.
append
(
change_point
)
else
:
# change point is after windows end
points_after_window
.
append
(
change_point
)
else
:
# change point is before windows start
points_before_window
.
append
(
change_point
)
return
(
points_before_window
,
points_in_window
,
points_after_window
)
class
ChangePoint
(
object
):
def
__init__
(
self
,
from_
,
to_
,
at_
,
prev_value_len_
,
attr_name_
):
self
.
prev_value
=
from_
...
...
@@ -202,20 +295,55 @@ class ChangePoint(object):
class
LHS_element
(
object
):
def
__init__
(
self
,
len_
,
value_
,
attr_name_
):
self
.
len
_
=
len_
self
.
value
_
=
value_
self
.
len
=
len_
self
.
value
=
value_
self
.
attr_name_
=
attr_name_
def
__repr__
(
self
):
return
(
str
(
self
.
attr_name_
)
+
": "
+
str
(
self
.
value_
)
+
"{"
+
str
(
self
.
len_
)
+
"}"
)
return
(
str
(
self
.
attr_name_
)
+
": "
+
str
(
self
.
value
)
+
"{"
+
str
(
self
.
len
)
+
"}"
)
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
LHS_element
):
return
((
self
.
len
==
other
.
len
)
and
(
self
.
value
==
other
.
value
)
and
(
self
.
attr_name_
==
other
.
attr_name_
))
else
:
return
False
def
__ne__
(
self
,
other
):
return
(
not
self
.
__eq__
(
other
))
def
__hash__
(
self
):
return
hash
(
self
.
__repr__
())
class
Rule
(
object
):
def
__init__
(
self
,
lhs
,
rhs
):
self
.
lhs
=
lhs
self
.
rhs
=
rhs
self
.
number_of_occurrences
=
0
self
.
last_occurrence
=
-
1
def
__repr__
(
self
):
return
(
str
(
self
.
lhs
)
+
" ==> "
+
str
(
self
.
rhs
))
return
(
str
(
self
.
lhs
)
+
" ==> "
+
str
(
self
.
rhs
)
+
" nrOcc:"
+
str
(
self
.
number_of_occurrences
)
+
" lastOcc:"
+
str
(
self
.
last_occurrence
))
# + "nr:" + str(self.number_of_occurrences) + " lastOcc:" + str(self.last_occurrence)
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
Rule
):
return
((
self
.
lhs
==
other
.
lhs
)
and
(
self
.
rhs
==
other
.
rhs
))
else
:
return
False
def
__ne__
(
self
,
other
):
return
(
not
self
.
__eq__
(
other
))
def
__hash__
(
self
):
return
hash
(
str
(
self
.
lhs
)
+
" ==> "
+
str
(
self
.
rhs
))
def
increment_occurrences
(
self
):
self
.
number_of_occurrences
+=
1
def
set_last_occurence
(
self
,
last
):
self
.
last_occurrence
=
last
def
round_to_hundreds
(
x
):
return
int
(
round
(
x
/
100.0
))
*
100
\ No newline at end of file
This diff is collapsed.
Click to expand it.
sequences/sequence_2018_04_13-22.33.30.csv
0 → 100644
View file @
d4b9865e
attr_1,attr_2,attr_3,attr_4
4,4,2,1
2,4,1,1
2,4,1,1
2,4,1,1
3,4,1,1
2,4,1,1
2,4,1,1
2,4,3,1
2,4,1,1
4,4,1,1
2,4,1,1
2,4,1,1
3,4,5,1
2,4,5,1
2,4,1,1
2,4,3,1
2,4,5,1
2,4,1,1
2,4,2,1
2,4,1,1
2,4,4,1
4,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,4,1
3,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
4,4,1,1
3,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
3,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,1,1
2,4,2,1
4,1,1,1
2,4,1,1
4,5,5,1
2,4,1,1
2,4,1,1
2,4,1,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file @
d4b9865e
import
numpy
as
np
import
sys
;
sys
.
path
.
append
(
'./detectors/'
)
import
pandas
as
pd
import
random
import
encoders
as
en
from
detector
import
ChangeDetector
from
detector
import
OnlineSimulator
...
...
@@ -13,11 +14,36 @@ def round_to_hundreds(x):
#Numerical data
#df = pd.read_csv('sequences/sequence_2017_11_28-18.07.57.csv')
#seq = np.array(df['attr_1'])
df
=
pd
.
read_csv
(
'sequences/sequence_2018_03_25-17.24.22.csv'
)
#df = pd.read_csv('sequences/sequence_2018_03_25-17.24.22.csv')
df
=
pd
.
read_csv
(
'sequences/sequence_2018_04_13-22.33.30.csv'
)
seq1
=
np
.
array
(
df
[
'attr_1'
])
seq2
=
np
.
array
(
df
[
'attr_2'
])
seq3
=
np
.
array
(
df
[
'attr_3'
])
seq4
=
np
.
array
(
df
[
'attr_4'
])
for
i
in
range
(
2
):
# rand = [random.randint(1,6) for i in range(random.randint(0,3)+50)]
# seq1_rand = np.concatenate((seq1, rand))
# seq1 = np.concatenate((seq1_rand, seq1))
#
# rand = [random.randint(1,6) for i in range(random.randint(0,3)+50)]
# seq2_rand = np.concatenate((seq2, rand))
# seq2 = np.concatenate((seq2_rand, seq2))
#
# rand = [random.randint(1,6) for i in range(random.randint(0,3)+50)]
# seq3_rand = np.concatenate((seq3, rand))
# seq3 = np.concatenate((seq3_rand, seq3))
#
# rand = [random.randint(1,6) for i in range(random.randint(0,3)+50)]
# seq4_rand = np.concatenate((seq4, rand))
# seq4 = np.concatenate((seq4_rand, seq4))
seq1
=
np
.
concatenate
((
seq1
,
seq1
))
seq2
=
np
.
concatenate
((
seq2
,
seq2
))
seq3
=
np
.
concatenate
((
seq3
,
seq3
))
seq4
=
np
.
concatenate
((
seq4
,
seq4
))
print
(
"seq len:"
,
len
(
seq1
))
# Symbolic data
# df = pd.read_csv('sequences/sequence_2017_11_22-19.35.27.csv')
# sequence = np.array(df['day_of_week'])
...
...
@@ -26,8 +52,9 @@ seq4 = np.array(df['attr_4'])
win_size
=
int
(
len
(
seq1
)
*
(
1
/
100
))
print
(
"win size:"
,
win_size
)
detector1
=
ZScoreDetector
(
window_size
=
win_size
,
threshold
=
3
)
detector1
=
ZScoreDetector
(
window_size
=
win_size
,
threshold
=
5
)
detector2
=
ZScoreDetector
(
window_size
=
win_size
,
threshold
=
3.5
)
#detector3 = ZScoreDetector(window_size = win_size, threshold=3)
detector4
=
ZScoreDetector
(
window_size
=
win_size
,
threshold
=
3
)
simulator
=
OnlineSimulator
([
detector1
,
detector2
,
detector4
],
...
...
@@ -38,5 +65,10 @@ simulator.run(plot=False)
#print(simulator.get_detected_changes())
detected_change_points
=
np
.
array
(
simulator
.
get_detected_changes
())
for
cps
in
detected_change_points
:
print
(
cps
)
\ No newline at end of file
# for cps in detected_change_points:
# print(cps)
print
()
for
r
in
simulator
.
get_rules
():
print
(
r
)
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