如何从列表中检测出局限器
我有一个带有值的列表。从此列表中,我想获得Outliners。
list_of_values = [2, 3, 100, 5, 53, 5, 4, 7]
def detect_outlier(data):
threshold= 3
mean_1 = np.mean(data)
std_1 =np.std(data)
outliers = [y for y in data if (np.abs((y - mean_1)/std_1) > threshold)]
return outliers
print(detect_outlier(list_of_values))
但是,我的印刷品空无一人,又名A []没有任何内容。有什么想法吗?
I have a list with values. From this list I would like to get the outliners.
list_of_values = [2, 3, 100, 5, 53, 5, 4, 7]
def detect_outlier(data):
threshold= 3
mean_1 = np.mean(data)
std_1 =np.std(data)
outliers = [y for y in data if (np.abs((y - mean_1)/std_1) > threshold)]
return outliers
print(detect_outlier(list_of_values))
However, my print turns up empty, aka a [] without anything in it. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于std_1 = 33.413,因此list_of_values中除以std_1的任何元素都将小于阈值,因此未产生。
Since std_1 = 33.413, any element in list_of_values divided by std_1 will be smaller than the threshold and hence not yielded.