Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jasonwbarnett/0e664546592c97367823 to your computer and use it in GitHub Desktop.
Save jasonwbarnett/0e664546592c97367823 to your computer and use it in GitHub Desktop.
def mad_based_outlier(points, thresh=3.5):
if len(points.shape) == 1:
points = points[:,None]
median = np.median(points, axis=0)
diff = np.sum((points - median)**2, axis=-1)
diff = np.sqrt(diff)
med_abs_deviation = np.median(diff)
modified_z_score = 0.6745 * diff / med_abs_deviation
return modified_z_score > thresh
7 com.spigit.lib
51 com.spigit.servlets
60 com.spigit.task
80 com.spigit.site
80 com.spigit.widget
85 com.spigit.tx
96 com.spigit.email
120 com.spigit.prediction
120 com.spigit.web
168 com.spigit.analysis
168 com.spigit.lang
168 com.spigit.seo
168 com.spigit.sitetemplate
222 com.spigit.privatemessage
226 com.spigit.util
315 com.spigit.filter
412 com.spigit.ws
512 com.spigit.core
624 com.spigit.event
672 com.spigit.pairwise
792 com.spigit.activitystream
801 com.spigit.sitechallenge
3678 com.spigit.community
4021 com.spigit.api
16803 com.spigit.model
27110 com.spigit.entity
207447 com.spigit.config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment