MulaiMulai sekarang secara gratis

Alternative way of classifying with IForest

Until now, you have been using the .fit_predict() method to fit IForest and generate predictions simultaneously. However, pyod documentation suggests using the fit function first and accessing the inlier/outlier labels_ via a handy attribute.

You will practice this on the big_mart dataset.

Latihan ini adalah bagian dari kursus

Anomaly Detection in Python

Lihat Kursus

Petunjuk latihan

  • Fit (only fit) the IForest() estimator to big_mart.
  • Access the training labels and store them as labels.
  • Use pandas subsetting on big_mart to filter the outliers into outliers.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

iforest = IForest(n_estimators=200)

# Fit (only fit) it to the Big Mart sales
____

# Access the labels_ for the data
labels = iforest.____

# Filter outliers from big_mart
outliers = ____[____]

print(len(outliers))
Edit dan Jalankan Kode