Skip to content

Instantly share code, notes, and snippets.

@strumer69
Last active March 29, 2023 15:43
Show Gist options
  • Save strumer69/b93a0d54ef2ff06755eeb89938e1faf8 to your computer and use it in GitHub Desktop.
Save strumer69/b93a0d54ef2ff06755eeb89938e1faf8 to your computer and use it in GitHub Desktop.
detecting outliers
def detect_outliers(data):
outliers=[]
threshold=3
mean = np.mean(data)
std =np.std(data)
for i in data:
z_score= (i - mean)/std
if np.abs(z_score) > threshold:# if z_score of a data is bigger than 3, it is outlier
outliers.append(i)
return outliers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment