LoslegenKostenlos loslegen

LOF for the first time

LOF differs from KNN only in the internal algorithm and the lack of the method parameter. Practice detecting outliers with it using contamination filtering on the scaled version of females dataset from previous exercises.

The dataset has been loaded as females_transformed.

Diese Übung ist Teil des Kurses

Anomaly Detection in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the LOF estimator from the relevant pyod module.
  • Instantiate an LOF() with 0.3% contamination, 20 neighbors and n_jobs set to -1.
  • Create a boolean index that returns True values when the labels_ returned from lof are equal to 1.
  • Isolate the outliers from females_transformed using is_outlier.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import LOF from its relevant module
from pyod.____ import ____

# Instantiate LOF and fit to females_transformed
lof = ____
lof.____

# Create a boolean index that checks for outliers
is_outlier = ____

# Isolate the outliers
outliers = ____

print(len(outliers))
Code bearbeiten und ausführen