Calculating outlier limits with IQR
Visualizing outliers is usually only the first step in detecting outliers. To go beyond visualizing outliers, you will need to write code that isolates the outliers from the distribution.
In this exercise, you will implement the first step of what's going on under the hood of the boxplot. In other words, you will calculate the lower and upper outlier limits manually.
The distribution is available as prices.
Cet exercice fait partie du cours
Anomaly Detection in Python
Instructions
- Calculate the first and third quartiles of prices and store these as
q1andq3, respectively. - Calculate the IQR score into
IQR. - Calculate the lower outlier limit into
lower_limit. - Calculate the upper outlier limit into
upper_limit.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Calculate the 25th and 75th percentiles
q1 = prices.____(____)
q3 = prices.____(____)
# Find the IQR
IQR = ____
factor = 2.5
# Calculate the lower limit
lower_limit = ____ - ____
# Calculate the upper limit
upper_limit = ____ + ____