Created
February 1, 2021 16:24
-
-
Save letthedataconfess/6f2645fc156842b972fb948b9c0dc195 to your computer and use it in GitHub Desktop.
outlier detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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