Skip to content

Instantly share code, notes, and snippets.

@letthedataconfess
Created February 1, 2021 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letthedataconfess/80ced9483c3485b623fa0e8cb1d00ecd to your computer and use it in GitHub Desktop.
Save letthedataconfess/80ced9483c3485b623fa0e8cb1d00ecd to your computer and use it in GitHub Desktop.
outlier_detection
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]
dataset=sorted(dataset)
q1, q3= np.percentile(dataset,[25,75])
iqr = q3 - q1
lower_bound = q1 -(1.5 * iqr)
upper_bound = q3 +(1.5 * iqr)
print('lower_bound={},upper_bound={}'.format(lower_bound,upper_bound))
outliers_pt=[]
for x in dataset:
if x<lower_bound or x>upper_bound:
outliers_pt.append(x)
outliers_pt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment