Skip to content

Commit

Permalink
Small correction in Shallow outliers predictor to make it a bit more …
Browse files Browse the repository at this point in the history
…accurate
  • Loading branch information
Pablo Rodríguez Flores committed Jul 4, 2024
1 parent bcb476b commit 83d0d62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion resources/src/ai/shallow_outliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 83d0d62

Please sign in to comment.