一、基于分布的方法1. 3sigma基于正态分布,3sigma准则认为超过3sigma的数据为异常点。图1: 3sigmadef three_sigma(s): mu, std = np.mean(s), np.std(s) lower, upper = mu-3*std, mu+3*std return lower, upper2. Z-scoreZ-score为标准分数,测量数据点和平均值的距离,若A与平均值相差2个标准差,Z-score为2。当把Z-score=3作为阈值去剔除异常点时,便相当于3sigma。def z_score(s): z_score = (s - np.mean(s)) / np.std(s) return z_score3. boxplot箱线图时基于四分位距(IQR)找异常点的。图2: boxplotdef boxplot(s): q1, q3 = s.quantile(.25), s.quantile(.75) iqr = q3 - q1 lower, upper = q1 - 1.5*iqr, q3 + 1.5*iqr return lower, upper4. Grubbs假设检验资料来源:[1] 时序预测竞赛之异常检测算法综述 - 鱼遇雨欲语与余,知乎:https://zhuanlan.zhihu.com/p/336944097[2] 剔除异常值栅格计算器_数
………………………………