今天看啥  ›  专栏  ›  数据派THU

【机器学习】14种异常检测方法总结!

数据派THU  · 公众号  · 大数据  · 2024-04-14 12:26
来源:机器学习初学者本文约7700字,建议阅读15分钟本文收集整理了公开网络上一些常见的异常检测方法(附资料来源和代码)。本文收集整理了公开网络上一些常见的异常检测方法(附资料来源和代码)。不足之处,还望批评指正。一、基于分布的方法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* ………………………………

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