Last active
March 29, 2023 15:43
-
-
Save strumer69/b93a0d54ef2ff06755eeb89938e1faf8 to your computer and use it in GitHub Desktop.
detecting outliers
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
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