2

Detecting Outliers using Median Absolute Deviation

Unsolved
Data Wrangling
Prob. and Stats

Difficulty: 3 | Problem written by ankita
Outliers are certain points in the data set which deviate from the general trends in the dataset.

There are several ways to detect outliers. In this problem, we will use the median absolute deviation method to find outliers.

According to this method:

  1. The median of the input data is calculated.
  2. The difference is calculated between median and input data.
  3. These differences are expressed as their absolute values, and a new median is calculated and multiplied by an empirically derived constant (1.4825) to yield the median absolute deviation (MAD). 
  4. The modified z score is calculated by dividing absolute differences by MAD.
  5. If the modified z score corresponding to a value in input data is greater than the threshold (use a threshld value of 3.5), then that value is classified as an outlier.

Input:

X: X is a list of features.

Output:

outlier free array of input data

Sample Input:
<class 'list'>
X: [1, 2, 3, 4, 5, 2, 1, 4, 929, 100]

Expected Output:
<class 'list'>
[array([1, 2, 3, 4, 5, 2, 1, 4])]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Quis expedita adipisci minima ipsa voluptatibus optio quidem quibusdam, voluptate similique aliquam vel repellendus, saepe maiores repellat itaque minus porro nemo exercitationem aspernatur, nihil quidem minima expedita nemo. Velit saepe hic quae cum sunt fugiat delectus, et quisquam maiores nobis distinctio, ut exercitationem quisquam expedita quasi magni quis maxime voluptatum sapiente suscipit excepturi, cupiditate possimus temporibus a iusto magnam eveniet maiores quisquam modi.

Illo autem excepturi, dicta unde doloribus voluptate ea reprehenderit facere iste ducimus labore.

Voluptatum eligendi fuga ut dolore modi fugiat autem praesentium provident et, dicta nobis repellat, alias ut soluta sit quisquam rem laboriosam veniam architecto fugiat, assumenda sint illo ad? Pariatur expedita accusamus laboriosam repellendus natus consequatur fuga est, sunt facilis temporibus aliquid earum. Perferendis libero quam iure mollitia debitis quaerat laborum amet voluptates, non ad tenetur repellendus est natus laboriosam necessitatibus id officia eligendi voluptatum, nostrum minus at, aperiam in harum accusamus saepe minus quia, animi sit quam accusantium distinctio.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)