DHI/tsod

Hampel filter inconsistent

ecomodeller opened this issue · 1 comments

The version without numba identfies constant values as anomalies

import pandas as pd
import tsod.hampel

df = pd.read_csv("https://raw.githubusercontent.com/DHI/tsod/main/tests/data/example.csv", parse_dates=True, index_col=0)
series = df.value

hdn = tsod.hampel.HampelDetector(threshold=3,window_size=10,use_numba=True)
resn = hdn.detect(series)
hd = tsod.hampel.HampelDetector(threshold=3,window_size=10,use_numba=False)
res = hd.detect(series)
plt.figure(figsize=(16,4))
plt.plot(series)
plt.plot(series[resn], 'bo',label='With numba')
plt.plot(series[res], 'r+',label='Without numba')
plt.legend()

image

Non-numba version removed