Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
outlier detection
import numpy as np
outliers=[]
dataset=[11,10,12,14,12,15,14,13,15,102,12,14,17,19,107,10,13,12,14,12,108,12,11,14,13,15,10,15,12,10,14,13,15,10]
def detect_outliers(data):
threshold=3
mean=np.mean(data)
std=np.std(data)
for i in dataset:
z_score=(i-mean)/std
if np.abs(z_score)>threshold:
outliers.append(i)
return outliers;
outlier_pt=detect_outliers(dataset)
print(outliers_pt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment