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
.
Este ejercicio forma parte del curso
Anomaly Detection in Python
Instrucciones del ejercicio
- Calculate the first and third quartiles of prices and store these as
q1
andq3
, respectively. - Calculate the IQR score into
IQR
. - Calculate the lower outlier limit into
lower_limit
. - Calculate the upper outlier limit into
upper_limit
.
Ejercicio interactivo práctico
Prueba este ejercicio completando el código de muestra.
# 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 = ____ + ____