From 83d0d622a6893ca500e7e5857902ecb2de352aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Rodr=C3=ADguez=20Flores?= Date: Thu, 4 Jul 2024 15:43:27 +0100 Subject: [PATCH] Small correction in Shallow outliers predictor to make it a bit more accurate --- resources/src/ai/shallow_outliers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/src/ai/shallow_outliers.py b/resources/src/ai/shallow_outliers.py index 49c4ccc..e930717 100644 --- a/resources/src/ai/shallow_outliers.py +++ b/resources/src/ai/shallow_outliers.py @@ -80,7 +80,10 @@ def predict(self, arr): window_size += 1 if window_size % 2 == 0 else 0 half_size = window_size // 2 kernel = np.linspace(1, half_size, half_size, dtype=float) - kernel = np.concatenate((kernel, [half_size**2 * 0.25], kernel[::-1])) + kernel = np.concatenate((kernel, [0], kernel[::-1])) + # Give way more importance to points around the one being predicted + kernel[half_size] = kernel.sum() + kernel = kernel**2 kernel /= kernel.sum() padded_arr = np.pad(arr, half_size, mode='edge') smooth_arr = np.convolve(padded_arr, kernel, mode='valid')