看啥推荐读物
专栏名称: Python开发
分享Python相关技术文章、学习资料、视频教程、热点资讯、工具资源、课程书籍等。每天推送,欢迎投稿!
今天看啥  ›  专栏  ›  Python开发

如何检验数据异常?

Python开发  · 公众号  ·  · 2024-04-03 14:29
架构师大咖 架构师大咖,打造有价值的架构师交流平台。分享架构师干货、教程、课程、资讯。架构师大咖,每日推送。 公众号该公众号已被封禁一、基于分布的方法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 - ………………………………

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