Skip to content
Snippets Groups Projects
Commit 87e13049 authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Added option to adjust outer fences using global mean for Boxplot method.

parent 6e7f124a
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
@author: Laura C. Kühle, Soraya Terrab (sorayaterrab) @author: Laura C. Kühle, Soraya Terrab (sorayaterrab)
TODO: Introduce Adjusted Outer Fence method in Boxplot using global_mean TODO: Introduce Adjusted Outer Fence method in Boxplot using global_mean
-> Done
TODO: Introduce overlapping cell for adjacent folds in Boxplot TODO: Introduce overlapping cell for adjacent folds in Boxplot
TODO: Introduce lower/upper extreme outliers in Boxplot 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)
...@@ -339,6 +340,8 @@ class Boxplot(WaveletDetector): ...@@ -339,6 +340,8 @@ class Boxplot(WaveletDetector):
Length of folds considered in one Boxplot. Length of folds considered in one Boxplot.
whisker_len : int whisker_len : int
Length of Boxplot whiskers. Length of Boxplot whiskers.
adjust_outer_fences : bool
Flag whether outer fences should be adjusted using global mean.
""" """
def _reset(self, config): def _reset(self, config):
...@@ -355,6 +358,7 @@ class Boxplot(WaveletDetector): ...@@ -355,6 +358,7 @@ class Boxplot(WaveletDetector):
# Unpack necessary configurations # Unpack necessary configurations
self._fold_len = config.pop('fold_len', 16) self._fold_len = config.pop('fold_len', 16)
self._whisker_len = config.pop('whisker_len', 3) self._whisker_len = config.pop('whisker_len', 3)
self._adjust_outer_fences = config.pop('adjust_outer_fences', True)
def _get_cells(self, multiwavelet_coeffs, projection): def _get_cells(self, multiwavelet_coeffs, projection):
"""Calculates troubled cells using multiwavelet coefficients. """Calculates troubled cells using multiwavelet coefficients.
...@@ -374,6 +378,12 @@ class Boxplot(WaveletDetector): ...@@ -374,6 +378,12 @@ class Boxplot(WaveletDetector):
""" """
indexed_coeffs = [[multiwavelet_coeffs[0, i], i] indexed_coeffs = [[multiwavelet_coeffs[0, i], i]
for i in range(self._mesh.num_grid_cells)] for i in range(self._mesh.num_grid_cells)]
# max_multiwavelets = [multiwavelet_coeffs[0, i]
# for i in range(self._mesh.num_grid_cells)]
# global_mean_old = np.mean(abs(np.array(max_multiwavelets)))
if self._adjust_outer_fences:
global_mean = np.mean(abs(np.array(indexed_coeffs)[:, 0]))
# print(global_mean == global_mean_old)
if self._mesh.num_grid_cells < self._fold_len: if self._mesh.num_grid_cells < self._fold_len:
self._fold_len = self._mesh.num_grid_cells self._fold_len = self._mesh.num_grid_cells
...@@ -400,6 +410,11 @@ class Boxplot(WaveletDetector): ...@@ -400,6 +410,11 @@ class Boxplot(WaveletDetector):
upper_bound = third_quartile \ upper_bound = third_quartile \
+ self._whisker_len * (third_quartile-first_quartile) + self._whisker_len * (third_quartile-first_quartile)
# Adjust outer fences if flag is set
if self._adjust_outer_fences:
lower_bound = min(-global_mean, lower_bound)
upper_bound = max(global_mean, upper_bound)
# Check for lower extreme outliers and add respective cells # Check for lower extreme outliers and add respective cells
for cell in sorted_fold: for cell in sorted_fold:
if cell[0] < lower_bound: if cell[0] < lower_bound:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment