【发布时间】:2021-11-06 16:58:52
【问题描述】:
如何检测离群值取决于其邻居。
我尝试检测道路上的车道,但由于路标和其他原因,存在空值(-1)和噪音。 对于 null 值,我将使用此方法进行桥接。
def bridging(ar: np.ndarray):
v_start = 0
temp = 0
latch = False
for e, v in enumerate(ar):
if not latch:
if v == -1: # enter -1 values
latch = True
v_start = e
temp = ar[e-1]
if latch:
if v != -1:
latch = False
v_length = e - v_start + 2
fill_values = np.linspace(temp, v, v_length)
ar[v_start:e] = fill_values[1:-1]
return ar
但在应用此方法之前,我必须检测并删除依赖于其邻居的异常值。
我尝试使用 Savitzky Golay Filtering https://scipy-cookbook.readthedocs.io/items/SavitzkyGolay.html 但这不能接受空值。
粗体示例粗体应被检测为异常值([184, -1, -1, -1, 756, 430, 473, 567, 618, 589, 585, 464, 467, 184, -1, 642, -1, 389, 387, -1, 589, 602, 728, 597, 568, 620, 610、548、424、-1、-1、301、-1、-1、-1、-1、637]、[-1、-1、3686、-1、3740、3653、-1、3656、 3633, -1, -1, 3421、3389、3560、-1、-1、-1、3340、3313、-1、3418、3566、 3643、3751、3580、3686、3683、3625、3515、3467、-1、3431、-1、 -1, -1, -1, -1]
【问题讨论】:
-
你能解释一下是什么让每个粗体项目成为异常值吗?这将使您更清楚您希望差距在识别异常值方面发挥什么作用。 (关于桥接的代码 sn-p 似乎主要是在转移注意力,与异常值本身不太相关。)
标签: python numpy scipy filtering outliers