Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

median absolute deviation or mean absolute deviation #8

Open
ColaBH opened this issue Aug 15, 2018 · 2 comments
Open

median absolute deviation or mean absolute deviation #8

ColaBH opened this issue Aug 15, 2018 · 2 comments

Comments

@ColaBH
Copy link

ColaBH commented Aug 15, 2018

The primary algorithm uses median absolute deviation to replace standard deviation, to make it more robust against anomaly points.

But in this code, pandas.mad() is used. However, pandas.mad() is mean absolute deviation, not median absolute deviation. Both can work, but median absolute deviation is better, in my opinion.

@hokiegeek2
Copy link
Contributor

hokiegeek2 commented Sep 19, 2018

@ColaBH Interesting, have you tested both versions to see which is better? @Marcnuth depending upon how testing goes, should this be configurable (median/mean absolute deviation)?

@kstseng
Copy link

kstseng commented Jan 25, 2019

I think which is better or not may depend on what data look like.
In my data, there is no big difference because of my time series data didn't have really big or small value. So the difference between median absolute deviation and mean absolute deviation is not huge.
But if your data may have really big or small value, I think the median absolute deviation is more robust.

And if you want to try to use median absolute deviation, you can try the following modification.
The original version:
https://github.com/Marcnuth/AnomalyDetection/blob/master/anomaly_detection/anomaly_detect_ts.py#L560

ares = ares / data.mad()

And I change to use median absolute deviation:

from statsmodels import robust
ares = ares / robust.mad(data.dropna())

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants