看啥推荐读物
专栏名称: Python开发者
人生苦短,我用 Python。伯乐在线旗下账号「Python开发者」分享 Python 相关的技术文章、工具资源、精选课程、热点资讯等。
今天看啥  ›  专栏  ›  Python开发者

如何检验数据异常?

Python开发者  · 公众号  · Python  · 2024-03-22 08:30
一、基于分布的方法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] 剔除异常值栅格计算器_数 ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照