Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
61c59d46
Commit
61c59d46
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added option to only report extreme outliers for Boxplot method.
parent
89aa2bb8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Troubled_Cell_Detector.py
+32
-8
32 additions, 8 deletions
Troubled_Cell_Detector.py
with
32 additions
and
8 deletions
Troubled_Cell_Detector.py
+
32
−
8
View file @
61c59d46
...
...
@@ -5,7 +5,7 @@
TODO: Vectorize _get_cells() in Boxplot method -> Done
TODO: Restructure Boxplot method -> Done
TODO: Introduce lower/upper extreme outliers in Boxplot
(each cell is also checked for neighboring domains if existing)
(each cell is also checked for neighboring domains if existing)
-> Done
TODO: Determine max_value for Theoretical only over highest degree
TODO: Check if indexing in wavelets is correct
TODO: Add ThresholdDetector
...
...
@@ -340,13 +340,15 @@ class Boxplot(WaveletDetector):
Length of Boxplot whiskers.
adjust_outer_fences : bool
Flag whether outer fences should be adjusted using global mean.
extreme_outlier_only : bool
Flag whether outliers also have to be detected in neighbouring folds.
folds : ndarray
Array with indices for elements of each fold (including
overlaps).
"""
def
_reset
(
self
,
config
):
"""
Reset
s
instance variables.
"""
Reset instance variables.
Parameters
----------
...
...
@@ -360,6 +362,7 @@ class Boxplot(WaveletDetector):
self
.
_fold_len
=
config
.
pop
(
'
fold_len
'
,
16
)
self
.
_whisker_len
=
config
.
pop
(
'
whisker_len
'
,
3
)
self
.
_adjust_outer_fences
=
config
.
pop
(
'
adjust_outer_fences
'
,
True
)
self
.
_extreme_outlier_only
=
config
.
pop
(
'
extreme_outlier_only
'
,
True
)
if
self
.
_mesh
.
num_grid_cells
<
self
.
_fold_len
:
self
.
_fold_len
=
self
.
_mesh
.
num_grid_cells
...
...
@@ -400,7 +403,7 @@ class Boxplot(WaveletDetector):
boundary_index
=
self
.
_fold_len
//
4
balance_factor
=
self
.
_fold_len
/
4.0
-
boundary_index
# Determine
bounds based on
first and third quartiles
of a boxplot
# Determine first and third quartiles
first_quartiles
=
(
1
-
balance_factor
)
\
*
folds
[:,
boundary_index
-
1
]
\
+
balance_factor
*
folds
[:,
boundary_index
]
...
...
@@ -408,11 +411,21 @@ class Boxplot(WaveletDetector):
*
folds
[:,
3
*
boundary_index
-
1
]
\
+
balance_factor
*
folds
[:,
3
*
boundary_index
]
lower_bounds
=
first_quartiles
-
self
.
_whisker_len
*
(
# Determine bounds based on quartiles of a boxplot
lower_bounds
=
np
.
zeros
(
len
(
first_quartiles
)
+
2
)
upper_bounds
=
np
.
zeros
(
len
(
first_quartiles
)
+
2
)
lower_bounds
[
1
:
-
1
]
=
first_quartiles
-
self
.
_whisker_len
*
(
third_quartiles
-
first_quartiles
)
upper_bounds
=
third_quartiles
+
self
.
_whisker_len
*
(
upper_bounds
[
1
:
-
1
]
=
third_quartiles
+
self
.
_whisker_len
*
(
third_quartiles
-
first_quartiles
)
# Adjust bounds to capture periodic boundary
lower_bounds
[
0
]
=
lower_bounds
[
-
2
]
lower_bounds
[
-
1
]
=
lower_bounds
[
1
]
upper_bounds
[
0
]
=
upper_bounds
[
-
2
]
upper_bounds
[
-
1
]
=
upper_bounds
[
1
]
# Adjust outer fences if flag is set
if
self
.
_adjust_outer_fences
:
global_mean
=
np
.
mean
(
abs
(
coeffs
))
...
...
@@ -420,9 +433,20 @@ class Boxplot(WaveletDetector):
upper_bounds
[
upper_bounds
<
global_mean
]
=
global_mean
# Select outliers as troubled cells
troubled_cells
=
np
.
flatnonzero
(
np
.
logical_or
(
coeffs
<
np
.
repeat
(
lower_bounds
,
self
.
_fold_len
),
coeffs
>
np
.
repeat
(
upper_bounds
,
self
.
_fold_len
))).
tolist
()
lower_outlier
=
coeffs
<
np
.
repeat
(
lower_bounds
[
1
:
-
1
],
self
.
_fold_len
)
upper_outlier
=
coeffs
>
np
.
repeat
(
upper_bounds
[
1
:
-
1
],
self
.
_fold_len
)
# Adjust for extreme outliers if flag is set
if
self
.
_extreme_outlier_only
:
lower_outlier
=
np
.
logical_and
(
lower_outlier
,
np
.
logical_and
(
coeffs
<
np
.
repeat
(
lower_bounds
[:
-
2
],
self
.
_fold_len
),
coeffs
<
np
.
repeat
(
lower_bounds
[
2
:],
self
.
_fold_len
)))
upper_outlier
=
np
.
logical_and
(
upper_outlier
,
np
.
logical_and
(
coeffs
>
np
.
repeat
(
upper_bounds
[:
-
2
],
self
.
_fold_len
),
coeffs
>
np
.
repeat
(
upper_bounds
[
2
:],
self
.
_fold_len
)))
troubled_cells
=
np
.
flatnonzero
(
np
.
logical_or
(
lower_outlier
,
upper_outlier
)).
tolist
()
return
troubled_cells
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment