MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Anomaly Detection in Python

Lihat Kursus

Petunjuk latihan

  • Calculate the first and third quartiles of prices and store these as q1 and q3, respectively.
  • Calculate the IQR score into IQR.
  • Calculate the lower outlier limit into lower_limit.
  • Calculate the upper outlier limit into upper_limit.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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 = ____ + ____
Edit dan Jalankan Kode