即使使用 IQR 方法删除异常值。异常值仍然存在于数据中

问题描述 投票:0回答:1

我使用箱线图方法找到了数据中的异常值。

enter image description here 应用 IQR 方法之前的箱线图

file1.shape
# (457, 11)

我已对数据应用了 IQR 方法。

q1, q2, q3 = file1['Salary'].quantile([0.25, 0.5, 0.75])
IQR = q3 - q1
f_data = file1[(file1['Salary'] > lower_bound) & (file1['Salary'] < upper_bound)]

我删除了一些数据点。

f_data.shape
# (420, 11)

但是,在使用箱线图查看过滤后的数据后,我仍然在数据中发现了一些异常值。

enter image description here 应用 IQR 方法后的箱线图。

我现在该怎么办。
我是否必须对过滤后的数据再次执行 IQR 方法?

薪资数据是右偏数据。它的偏斜值约为 1.5

或者我应该减小偏斜值。就像使用对数、幂方法一样。

machine-learning data-science outliers data-preprocessing iqr
1个回答
0
投票

我认为你错误地使用了 IQR,

q1, q3 = file1['Salary'].quantile([0.25, 0.75])
IQR = q3 - q1
lower_bound = q1 - 1.5 * IQR
upper_bound = q3+ 1.5 * IQR

然后

f_data = file1[(file1['Salary'] > lower_bound) & (file1['Salary'] < upper_bound)]

应该可以。

© www.soinside.com 2019 - 2024. All rights reserved.